Context
Parent: #160
The binary crate has ~320 lines of CLI dispatch logic in main.rs with ~1% test coverage. Functions like run_trace(), run_diff(), run_packages(), build_snapshot_from_working_tree(), and build_snapshot_from_ref() have zero tests. Three of eleven v0.4.0 bugs lived here (#142, #148, #150).
Expected Behavior
End-to-end tests that invoke the chainsaw binary with real arguments and assert on stdout, stderr, and exit codes.
Scope
- Add
assert_cmd (and optionally predicates) as dev-dependencies
- Create
tests/cli.rs integration test file
- Cover at minimum:
trace <entry> produces expected output format
trace --json <entry> produces valid JSON with expected field names
trace --chain <entry> <target> finds import chains
trace --cut <entry> <target> finds cut points
trace --max-weight <n> <entry> returns error when exceeded
diff <ref> with --entry produces diff output
diff --json <ref> --entry <entry> produces valid JSON
packages <entry> lists packages
packages --json <entry> produces valid JSON
- Invalid flag combinations return non-zero exit code with helpful error message
- Missing entry file returns non-zero exit code
- Use a small fixture project (2-3 .ts files) committed under
tests/fixtures/
Context
Parent: #160
The binary crate has ~320 lines of CLI dispatch logic in main.rs with ~1% test coverage. Functions like
run_trace(),run_diff(),run_packages(),build_snapshot_from_working_tree(), andbuild_snapshot_from_ref()have zero tests. Three of eleven v0.4.0 bugs lived here (#142, #148, #150).Expected Behavior
End-to-end tests that invoke the
chainsawbinary with real arguments and assert on stdout, stderr, and exit codes.Scope
assert_cmd(and optionallypredicates) as dev-dependenciestests/cli.rsintegration test filetrace <entry>produces expected output formattrace --json <entry>produces valid JSON with expected field namestrace --chain <entry> <target>finds import chainstrace --cut <entry> <target>finds cut pointstrace --max-weight <n> <entry>returns error when exceededdiff <ref>with--entryproduces diff outputdiff --json <ref> --entry <entry>produces valid JSONpackages <entry>lists packagespackages --json <entry>produces valid JSONtests/fixtures/