summaryrefslogtreecommitdiff
path: root/integration-tests
diff options
context:
space:
mode:
Diffstat (limited to 'integration-tests')
-rw-r--r--integration-tests/run_shell_command.test.js13
-rw-r--r--integration-tests/test-helper.js32
2 files changed, 36 insertions, 9 deletions
diff --git a/integration-tests/run_shell_command.test.js b/integration-tests/run_shell_command.test.js
index 04cc02fa..52aee194 100644
--- a/integration-tests/run_shell_command.test.js
+++ b/integration-tests/run_shell_command.test.js
@@ -14,7 +14,18 @@ test('should be able to run a shell command', async (t) => {
rig.createFile('blah.txt', 'some content');
const prompt = `Can you use ls to list the contexts of the current folder`;
- const result = await rig.run(prompt);
+ const result = rig.run(prompt);
+
+ assert.ok(result.includes('blah.txt'));
+});
+
+test('should be able to run a shell command via stdin', async (t) => {
+ const rig = new TestRig();
+ rig.setup(t.name);
+ rig.createFile('blah.txt', 'some content');
+
+ const prompt = `Can you use ls to list the contexts of the current folder`;
+ const result = rig.run({ stdin: prompt });
assert.ok(result.includes('blah.txt'));
});
diff --git a/integration-tests/test-helper.js b/integration-tests/test-helper.js
index eb598bd9..7acdc7aa 100644
--- a/integration-tests/test-helper.js
+++ b/integration-tests/test-helper.js
@@ -47,14 +47,30 @@ export class TestRig {
execSync('sync', { cwd: this.testDir });
}
- run(prompt, ...args) {
- const output = execSync(
- `node ${this.bundlePath} --yolo --prompt "${prompt}" ${args.join(' ')}`,
- {
- cwd: this.testDir,
- encoding: 'utf-8',
- },
- );
+ run(promptOrOptions, ...args) {
+ let command = `node ${this.bundlePath} --yolo`;
+ const execOptions = {
+ cwd: this.testDir,
+ encoding: 'utf-8',
+ };
+
+ if (typeof promptOrOptions === 'string') {
+ command += ` --prompt "${promptOrOptions}"`;
+ } else if (
+ typeof promptOrOptions === 'object' &&
+ promptOrOptions !== null
+ ) {
+ if (promptOrOptions.prompt) {
+ command += ` --prompt "${promptOrOptions.prompt}"`;
+ }
+ if (promptOrOptions.stdin) {
+ execOptions.input = promptOrOptions.stdin;
+ }
+ }
+
+ command += ` ${args.join(' ')}`;
+
+ const output = execSync(command, execOptions);
if (env.KEEP_OUTPUT === 'true') {
const testId = `${env.TEST_FILE_NAME.replace(