Skip to content

test(pi): no-prompt branch with --model emits --provider ollama (no -p)#22

Open
hggz wants to merge 2 commits intocapotej:mainfrom
hggz:feat/track-c-pi-no-prompt
Open

test(pi): no-prompt branch with --model emits --provider ollama (no -p)#22
hggz wants to merge 2 commits intocapotej:mainfrom
hggz:feat/track-c-pi-no-prompt

Conversation

@hggz
Copy link
Copy Markdown
Contributor

@hggz hggz commented Apr 26, 2026

test(pi): no-prompt branch with --model emits --provider ollama (no -p)

What

Covers the prompt === null arm of PiAdapter.buildCommand — i.e. interactive pi with -m and no -p:

if (prompt !== null) {
  return ["pi", "-p", prompt, ...providerArgs, ...modelArgs];
}
return ["pi", ...providerArgs, ...modelArgs];   // <-- this branch

Currently only the prompt+model arm is asserted by the existing test renamed in #16. This PR adds coverage for the no-prompt arm.

Why

That branch is only reachable when process.stdin.isTTY === true, so a plain spawnSync test cannot hit it (subprocess stdin is never a TTY). To exercise it, the new test allocates a pty via util-linux script:

spawnSync("script", ["-qfec", `node ${CLI} -m <model>`, "/dev/null"], )

…then strips CR characters from the output and parses the DOCKER_INVOKED line as usual. The test self-skips if command -v script is unavailable (it is preinstalled on ubuntu-latest).

The test asserts:

  • exit code 0
  • pi argv contains no stray -p
  • pi argv tail is exactly pi --provider ollama --model <model>

How verified

$ pnpm install --frozen-lockfile && pnpm build && pnpm test:e2e:cli
…
✔ pi: --model is forwarded with --provider ollama in local mode
✔ pi: interactive (no -p, no piped stdin) with --model emits 'pi --provider ollama --model X' (no -p)
…
ℹ tests 20
ℹ pass  20
ℹ fail  0

hggz added 2 commits April 26, 2026 20:57
Covers the `prompt === null` arm of `PiAdapter.buildCommand`. That branch
is only reachable when stdin is a TTY, so we allocate a pty via
util-linux `script` to fake interactive mode (and skip the test if
`script` is unavailable, though it is preinstalled on ubuntu-latest).

Asserts:
  * exit 0
  * pi argv contains no stray `-p`
  * pi argv tail is exactly `pi --provider ollama --model <model>`

Pairs with the existing positive (`-p` + `-m`) test to lock down both
arms of the no-env-file local-mode logic.

Verified locally: 20/20 tests pass.
@capotej
Copy link
Copy Markdown
Owner

capotej commented Apr 27, 2026

needs a rebase

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants