feat(xce-test-cli-ux): add command-name tab completion scoped to context
Registers libedit's GNU-readline-compatible rl_attempted_completion_function under g_interactive only. The candidate generator reads active_ctx->commands[] live on every call, so completion correctly tracks context switches rather than freezing at registration time. Single/multi-match UI (auto-complete vs. double-Tab candidate listing) is entirely libedit's stock behavior once given a correct context-scoped generator. Proven via a black-box pty test verified sound against a false-positive risk: xce_test has no fuzzy command-name matching, so an uncompleted partial token cannot coincidentally trigger the same effect a real completion would. Also fixes a harness bug (bug-1792): disabling kernel ECHO for output capture was silently suppressing libedit's own completion feedback too; added clitest_spawn_ex() with disable_echo as an explicit parameter, clitest_spawn() unchanged for existing callers. 1307/1307 controller suite passing (+1), re-verified 8/8 for flakiness. Task 2.3 of .kiro/specs/xce-test-cli-ux/tasks.md. Requirements: 7.1, 7.2, 7.3, 7.4 Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019jaMf9QEwpugH2W9KAuc7f
This commit is contained in:
parent
07d238eada
commit
0ef232a013
4 changed files with 356 additions and 14 deletions
|
|
@ -67,7 +67,7 @@
|
|||
- _Requirements: 5.1, 5.3_
|
||||
- _Boundary: JSON List Formatter_
|
||||
|
||||
- [ ] 2.3 (P) Build command-name tab completion scoped to the active context
|
||||
- [x] 2.3 (P) Build command-name tab completion scoped to the active context
|
||||
- Implement completion that, when the session is interactive, offers only command names valid in the currently active context, completes an unambiguous partial match in full, and lists candidates without altering the input line when more than one match exists
|
||||
- Observable completion: a black-box test (using the harness from 1.7) drives a partial command name plus a tab keypress in two different contexts and confirms the completion offered differs by context and matches the single-match/multiple-match behavior
|
||||
- _Requirements: 7.1, 7.2, 7.3, 7.4_
|
||||
|
|
@ -178,6 +178,7 @@
|
|||
## Implementation Notes
|
||||
- `src/tools/xce-build.sh controller asan xce.build --incremental` writes its build dir at `src/xce.build/` (relative to the script's own location), not a repo-root `xce.build/` — meson logs are at `src/xce.build/meson-logs/testlog.txt`. (task 1.1)
|
||||
- New Unity test files need two wiring points, not just meson.build's source list: also register an `extern void test_<module>(void);` + `TEST(test_<module>);` in `src/controller/testsuite/controller_test.c`, mirroring the existing `test_rcfile` registration, or the suite silently never runs. (task 1.1)
|
||||
- libedit (this project's pinned NetBSD libedit 3.1) provides GNU-readline-compatible `rl_attempted_completion_function`/`rl_completion_matches` verbatim — confirmed against the actual linked header, not assumed. An ambiguous match needs a SECOND consecutive Tab to list candidates (standard readline/bash double-Tab convention) — later black-box tests using Tab must account for this. Also: `test_test_cli.c`'s `clitest_spawn()` disabling kernel ECHO also silently suppressed libedit's own completion feedback in this libedit build (bug-1792) — use the new `clitest_spawn_ex(sess, path, argv, disable_echo)` with `disable_echo=false` for any future test that needs to observe libedit UI behavior (completion, etc.), not just raw command output. (task 2.3)
|
||||
- `listfmt_json.c`'s tests only exercise power-of-two double values (Unity's `TEST_ASSERT_EQUAL_DOUBLE` is disabled project-wide, matching `test_host_runusage.c`/`test_e2e_capnp.c`); cJSON's real print path uses shortest-round-trippable-double formatting so fractional values are fine, but task 3.4 should add a real fractional-value (e.g. a resource value like 12.34) round-trip test once actual command fields are wired in, since nothing here proves that end-to-end yet. (task 2.2)
|
||||
- `confirm_destructive()`'s EINTR-as-decline (9.9) works because it's a single, non-looping `fgets()` call — a naive "robust I/O" retry-on-EINTR wrapper would silently defeat this requirement. `g_interactive` is exposed via a new `xcetest_is_interactive()` accessor (declared in `confirm.h`, mirroring `xcetest_interrupted()`'s pattern) for task 3.3 to reuse. Task 3.3 must short-circuit around `confirm_destructive()` entirely (not pass a parameter into it) when a command's own `--yes` flag was given — the function has no bypass-flag parameter by design. (task 2.1)
|
||||
- The `test_test_cli.c` black-box harness (`clitest_*` functions) is file-static and single-file by design (matching design.md's File Structure Plan and this directory's own no-split norm) — tasks 2.3, 3.5, 4.1-4.4 should add their black-box test functions directly into this same file rather than a new one. `clitest_wait_for_text()` is generic (arbitrary needle/stream) and safe to call repeatedly mid-session; `clitest_send_signal()` targets the child's real pid via `kill()`. (task 1.7)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue