Skip to content

Commit 98e0d45

Browse files
committed
fix: adjust confirm test for Windows
1 parent 689611d commit 98e0d45

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

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)