Commit Graph

3 Commits

Author SHA1 Message Date
Valentin Maerten
e3b6ed4a03 test(completion): test the __complete protocol in Go, thin shell smokes
Follow cobra's testing philosophy: the completion protocol (candidates +
directive) is business logic and belongs in Go, while the shell wrappers only
need to be checked for how they interpret each directive.

- Add completion/protocol_test.go: a table-driven black-box test that runs the
  real `task __complete` binary and asserts the offered values and the emitted
  directive. Unlike the in-process engine tests, it exercises the actual
  entrypoint dispatch, runComplete wiring and — crucially — the real flag set,
  so it catches drift between the completion enum/directive maps and the flag
  definitions. Runs on every OS, including Windows where the shell smokes don't.
- Delete completion/tests/engine.sh (the protocol is now covered in Go) and drop
  it from run.sh.
- Reduce the bash/zsh/fish/powershell smokes to directive routing only (files vs
  dirs vs no-files vs no-space), removing the task/alias/var assertions that the
  Go tests already own.
2026-07-03 23:00:50 +02:00
Valentin Maerten
e5ecd46750 test(completion): clean up temp dirs via EXIT trap in run.sh 2026-07-03 22:33:27 +02:00
Valentin Maerten
7c90ee35f8 test(completion): add cross-shell completion test suite and CI job
Add completion/tests/ harnesses that exercise the engine protocol and every
shell wrapper without a TTY: the engine via `task __complete`, bash/zsh by
stubbing the completion-system helpers, fish via `complete -C`, and PowerShell
via the completion API. A `test:completion` task and a matching CI job (with a
strict mode that fails when an expected shell is missing) run them all.

Writing the suite surfaced and fixed real wrapper bugs:
- fish: `math` has no bitwise `&`, so every directive check errored; test bits
  with integer division + modulo instead. Also filter FilterFileExt results
  ourselves, as __fish_complete_suffix only prioritizes the extension.
- powershell: `Get-ChildItem -Include` is ignored without -Recurse, so file
  extension filtering returned nothing; filter with Where-Object instead.
- bash: guard empty-array expansion so completion with zero candidates does not
  trip `set -u` on bash 3.2.

Also name the completion directive bits (NO_SPACE, FILTER_FILE_EXT, …) in every
wrapper instead of using raw numbers.
2026-07-03 22:29:42 +02:00