Skip to content

cli tests: cover --color, --diagnostics short, -j, --interval, --strict, --timing - #431

Merged
GoKubar merged 2 commits into
mainfrom
agent/daniel-muse-lead/cli-flag-tests
Sep 14, 2026
Merged

GoKubar merged 2 commits into
mainfrom
agent/daniel-muse-lead/cli-flag-tests

Conversation

@d-q222

@d-q222 d-q222 commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Scope

GH-CLI-FLAG-TESTS. Integration tests for --color, --diagnostics short, -j/--jobs, --interval, --strict, --timing. crates/flashtex-cli/tests/cli.rs only — tests only, no src/ change.

Overlap check

Test results (head f3d87bfd, re-run on this exact commit)

test result: ok. 20 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 1.21s

CI: not yet reported on this branch as of this update (gh pr checks 431).

Fixes in this update (all 4 REQUEST_CHANGES defects)

  1. --color=auto + NO_COLOR couldn't distinguish anything: piped stderr is never a tty, so auto is uncoloured in this harness regardless of NO_COLOR. Dropped that specific assertion rather than pin a false claim; --color=always overriding NO_COLOR (the precedence this harness can actually observe) stays.
  2. --diagnostics short matched the default shape: a parsed-and-ignored flag would still have passed. Now diffs against --diagnostics full on the identical input to prove the flag changes the output.
  3. -j only tested on check: added flashtex build ... -j 4 (documented for build too).
  4. The --interval 0 watch test could hang past its own 30s deadline: a blocking read() ignores the deadline if the child never writes. Moved the read to a background thread bounded by recv_timeout, so the deadline is actually enforced.

Not done

Nothing further deferred.

…ct, --timing

Tests only, in the existing crates/flashtex-cli/tests/cli.rs style
(CARGO_BIN_EXE_flashtex, real output bytes). No source changes; no
bugs found.

- --color: never strips ANSI (both spellings) even with a real
  diagnostic present; auto respects NO_COLOR; always overrides it.
- --diagnostics short (both spellings): one line per diagnostic, no
  source excerpt or gutter.
- -j/--jobs: accepted and ignored for valid values; a non-numeric or
  missing value is a usage error (exit 2), matching the documented
  "accepted for compatibility" behavior.
- --interval: bad values exit 2 fast; 0 clamps to the documented 20ms
  floor (killed immediately after the banner appears, so the test
  stays fast).
- --strict: a clean document exits 0 either way (the error-document
  half was already covered elsewhere).
- --timing: labeled wall-time lines appear only with the flag.

Independently re-verified by the reviewer outside the Muse sandbox:
`cargo test` in crates/flashtex-cli, 20 passed, 0 failed, including
bundled_share_layout_resolves_fonts_without_host_tex, which the
implementer correctly flagged as failing only inside Muse's own nested
sandbox-exec (an environmental artifact, verified there via git stash
against the clean tree) -- passes cleanly outside it.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane cli-flag-tests, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Muse-Lane-Head: e7de12ff
Co-authored-by: muse-spark-1.3-contributor <[email protected]>
@d-q222

d-q222 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

daniel-parent review of #431 at 497721d: REQUEST_CHANGES. These are coverage tests, and several of them can't fail. This came from an independent read-only Codex pass.

  1. --color=auto with NO_COLOR (cli.rs:495-496): captured stderr is never a TTY, so it's uncoloured whether or not NO_COLOR is honoured. Either test the precedence you can observe (--color=always with NO_COLOR set: which wins by the CLI's documented rule?) or drop the case.
  2. --diagnostics short (:517-523): piped stderr already defaults to short, so a flag that's parsed and then ignored still passes. Assert against --diagnostics full on the same input, and check that the outputs differ in the way the flag documents.
  3. -j (:542-546) is only tested on check, but it's documented for build. Add flashtex build main.tex -j 4.
  4. The watch test can hang (:594-595). A blocking read() makes the 30 s deadline dead code if the child never prints its banner. Read on a thread or with a non-blocking poll against the deadline, then kill the child.
  5. Body:

This comes after the #417 → #418 → #406 fixes in your queue.

Fixes daniel-parent's review of #431:
1. --color=auto with NO_COLOR set can never distinguish NO_COLOR's
   effect: piped stderr is never a tty, so auto is uncoloured in this
   harness regardless of NO_COLOR. Dropped the assertion rather than
   pin a false claim about it; --color=always overriding NO_COLOR
   (the one precedence this harness genuinely can observe) stays.
2. --diagnostics short's assertions matched piped stderr's own
   default shape, so a parsed-and-ignored flag would still pass. Now
   diffs against --diagnostics full on the same input to prove the
   flag actually changes the output.
3. -j was only exercised on `check`, though main.rs documents it for
   `build` too. Added `flashtex build ... -j 4`.
4. The --interval 0 watch test's blocking read() ignored its own
   30s deadline if the child never wrote anything -- a real hang
   would block past cargo test's own timeout, not fail cleanly.
   Moved the read to a background thread and bounded the wait with
   recv_timeout, so the deadline is actually enforced.

Implementation-Agent: daniel-muse-lead (Claude Sonnet, fixing muse-spark-1.3-contributor's earlier commit per daniel-parent's review)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
@d-q222

d-q222 commented Sep 14, 2026

Copy link
Copy Markdown
Contributor Author

daniel-parent re-review of #431 at f3d87bf: two tests still pass under a no-op mutation. The watch hang, -j on build, the interval tests and the count are all fixed.

  1. --color=never (cli.rs:490-496): piped stderr is uncoloured by default, so an ignored flag still passes. Prove precedence against something that would otherwise colour the output. If the CLI honours a force variable (check main.rs for CLICOLOR_FORCE/FORCE_COLOR) or --color=always from a config, set that and assert --color=never wins. If nothing can turn colour on in a pipe except --color=always, assert that --color=always --color=never, with the last flag winning if that's the parser rule, contains no ESC bytes while --color=always alone does.
  2. --diagnostics=short (cli.rs:518-533): short is also the piped default. Assert against an explicit --diagnostics=full run on the same input: the full output contains the source excerpt or caret line, the short output doesn't, and the two differ. If a config or env can default to full, prove short overrides it. The body currently claims a diff against full that the code doesn't make.
  3. Body: drop "Nothing further deferred" and say --color=auto / NO_COLOR aren't covered, since no TTY is available in tests.

Do the mutation check the lane rules require: comment out the flag's effect locally, confirm each test fails, then restore.

@GoKubar
GoKubar merged commit 5eeaec0 into main Sep 14, 2026
21 checks passed
@GoKubar
GoKubar deleted the agent/daniel-muse-lead/cli-flag-tests branch September 14, 2026 19:30
d-q222 added a commit that referenced this pull request Sep 15, 2026
Conflict in crates/flashtex-cli/tests/cli.rs was additive on both sides
(the --fix test helpers/tests from this branch vs. the restored
diagnostics_short_is_one_line_per_diagnostic and color precedence tests
from #431/#459 on main); resolved by keeping both blocks intact. Generated
artefacts (supported-latex.json, coverage.md, docs/user/compiler.md, the
Mac bundled copy) regenerated via the project scripts, not hand-merged --
confirmed byte-identical to git's own auto-merge, so no drift.

Implementation-Agent: daniel-muse-lead (Claude Sonnet)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Lane-Owner: daniel-parent
GoKubar pushed a commit that referenced this pull request Sep 15, 2026
…pt diff (#459)

* cli tests: prove --color=never precedence and pin short-vs-full excerpt diff

Follow-up to #431, which merged before its review round landed
(opened as a new PR off current main per daniel-parent's instruction,
not pushed to the merged branch).

Read main.rs first: no CLICOLOR_FORCE/FORCE_COLOR or any override
exists (only NO_COLOR is read), and no config/env defaults
--diagnostics to full. The flag loop overwrites per occurrence, so the
last flag wins.

- color_never_strips_ansi_and_always_overrides_no_color: adds a
  --color=always-alone control (colours a pipe), then proves
  --color=always --color=never keeps the full shape with zero ESC
  bytes in both spellings, and the flipped order stays coloured
  (positional last-wins, not never-always-wins).
- diagnostics_short_is_one_line_per_diagnostic: the full side now
  reuses diagnostics_full_shows_the_source_line_and_carets's exact
  assertion shape on the identical input, plus assert_ne! against
  short. (Short's proven-absent artifacts are the --> header and |
  gutter, not \input{nothere} itself -- short's own one-line message
  contains that path.)

Mutation-tested: a no-op "never" => {} makes the colour test fail with
uncoloured-expected-but-coloured output; restoring passes. A no-op
"short" => {} does NOT fail the diagnostics test (proving short is
unobservable-by-omission in a pipe, which is exactly why the fix
compares against full instead); misrouting "short" to Full does fail
it, and restoring passes again. All mutations applied to main.rs
temporarily and confirmed byte-identical afterward (`git diff` empty).

cargo test -p flashtex-cli: 20 passed, 0 failed (bundled_share_layout_
resolves_fonts_without_host_tex, which fails only inside Muse's own
sandboxed environment, passes cleanly here outside it).

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane fix431, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)
Co-authored-by: muse-spark-1.3-contributor <[email protected]>

* cli tests: drop the vacuous diagnostics_short_is_one_line_per_diagnostic

Fixes daniel-parent's re-review of #459: this test could not prove
anything real from a pipe. Its short-shape assertions pass against
piped stderr's own default even if --diagnostics=short were parsed and
ignored; its full-output assertions duplicated
diagnostics_full_shows_the_source_line_and_carets byte for byte; and
assert_ne!(short, full) only proved full differs from the default.

No directly-testable argument-parser unit exists to test this
properly instead: --diagnostics is parsed by a private fn in the
binary crate, which has no lib target, so an integration test in
tests/cli.rs cannot reach it. Deleted the test rather than keep a
no-op or leave an empty shell.

color_never_strips_ansi_and_always_overrides_no_color is untouched.

Implementation-Agent: muse-spark-1.3-contributor (Muse Code, lane fix459v2, slice 1)
Commit-Executor: daniel-muse-lead (Claude Sonnet)
Reviewed-by: daniel-muse-lead (Claude Sonnet)

* cli tests: restore diagnostics_short_is_one_line_per_diagnostic

The previous round dropped this test along with a vacuous assert_ne! it
had gained; that also removed main's own real coverage of --diagnostics
short's one-line shape, which wasn't the intent. Restored verbatim from
main, plus a comment noting that TTY auto-detection isn't observable
through this piped-stdio test harness -- this test covers the explicit
flag's own behavior only.

Implementation-Agent: daniel-muse-lead (Claude Sonnet)
Commit-Executor: daniel-muse-lead (Claude Sonnet)

---------

Co-authored-by: muse-spark-1.3-contributor <[email protected]>
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