Skip to content

Commit abe1a57

Browse files
authored
Merge pull request #52 from thedadams/fix-confirm-test-windows
fix: adjust confirm test for Windows
2 parents 689611d + ce065fb commit abe1a57

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

Diff for: .github/workflows/run_tests.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,15 @@ jobs:
4747
- name: Install gptscript
4848
run: |
4949
curl https://get.gptscript.ai/releases/default_windows_amd64_v1/gptscript.exe -o gptscript.exe
50+
- name: Create config file
51+
run: |
52+
echo '{"credsStore":"file"}' > config
5053
- name: Install dependencies
5154
run: npm install
5255
- name: Run Tests
5356
env:
5457
GPTSCRIPT_BIN: .\gptscript.exe
58+
GPTSCRIPT_CONFIG_FILE: .\config
5559
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
5660
NODE_GPTSCRIPT_SKIP_INSTALL_BINARY: true
5761
run: npm test

Diff for: tests/gptscript.test.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -401,21 +401,24 @@ describe("gptscript module", () => {
401401
}, 10000)
402402

403403
test("confirm", async () => {
404-
let confirmFound = false
405404
const t = {
406405
instructions: "List the files in the current working directory.",
407406
tools: ["sys.exec"]
408407
}
408+
409+
const commands = [`"ls"`, `"dir"`]
410+
let confirmCallCount = 0
409411
const run = await g.evaluate(t, {confirm: true})
410412
run.on(gptscript.RunEventType.CallConfirm, async (data: gptscript.CallFrame) => {
411-
expect(data.input).toContain(`"ls"`)
412-
confirmFound = true
413+
// On Windows, ls is not always a command. The LLM will try to run dir in this case. Allow both.
414+
expect(data.input).toContain(commands[confirmCallCount])
415+
confirmCallCount++
413416
await g.confirm({id: data.id, accept: true})
414417
})
415418

416419
expect(await run.text()).toContain("README.md")
417420
expect(run.err).toEqual("")
418-
expect(confirmFound).toBeTruthy()
421+
expect(confirmCallCount > 0).toBeTruthy()
419422
})
420423

421424
test("do not confirm", async () => {

0 commit comments

Comments
 (0)