Repository navigation
Add --output <DIR> to list and write list --format files to the target directory - #5227
hiepnnguyentcu wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
With --no-codegen, Cargo list commands lose Cargo metadata and write kani-list.* to the current directory instead of honoring --target-dir.
1 open issue
What changed in this PR
This PR addresses #5124 by moving Cargo list files out of the source tree and adding explicit output-directory control for list and autoharness --list.
Changes:
- Add
--output <DIR>with validation and directory creation for JSON and Markdown output. - Default Cargo list files to
<target-dir>/kani/, while preserving the current-directory default for standalone commands. - Update documentation and regression tests for the output locations.
| File | Description |
|---|---|
tests/script-based-pre/cargo_list_output/src/lib.rs |
Add a minimal proof harness fixture. |
tests/script-based-pre/cargo_list_output/list.sh |
Test default, custom-target, and explicit output directories. |
tests/script-based-pre/cargo_list_output/list.expected |
Define expected output paths and harness entries. |
tests/script-based-pre/cargo_list_output/config.yml |
Register the new script test. |
tests/script-based-pre/cargo_list_output/Cargo.toml |
Define the test package. |
tests/script-based-pre/cargo_list_md/list.sh |
Read Markdown results from target/kani/. |
tests/script-based-pre/cargo_list_md/.gitignore |
Remove the obsolete source-root output exclusion. |
tests/script-based-pre/cargo_list_json/list.sh |
Read JSON results from target/kani/. |
kani-driver/src/list/output.rs |
Resolve default directories and create output files there. |
kani-driver/src/list/collect_metadata.rs |
Pass selected directories to list output generation. |
kani-driver/src/autoharness/mod.rs |
Apply output-directory selection to autoharness listings. |
kani-driver/src/args/list_args.rs |
Add and validate --output, with unit tests. |
kani-driver/src/args/autoharness_args.rs |
Add --output requiring --list, with validation tests. |
docs/src/reference/list.md |
Document the option and default output locations. |
docs/src/reference/experimental/autoharness.md |
Document autoharness list output locations and overrides. |
Review effort: Balanced
273874d to
c27f6c5
Compare
feliperodri
left a comment
There was a problem hiding this comment.
Thanks, this fixes #5124 cleanly. I checked it locally: the kani-driver unit tests and the list and autoharness script tests pass, and clippy and fmt are clean. In a cargo workspace, cargo kani list from a member crate writes to the workspace's target/kani/, CARGO_TARGET_DIR is respected, and a relative --output is resolved against the current directory. kani list --std, which verify-rust-std's run-kani.sh uses, still writes to the current directory, so it isn't affected. The --no-codegen fix for Copilot's comment is right, and the only other user of project.cargo_metadata is coverage, which isn't affected. Approving.
Non-blocking:
- The default location of
kani-list.*moves forcargo kani listandcargo kani autoharness --list, which breaks scripts that read./kani-list.json. Since the release notes are generated from PR titles, consider mentioning it in the title, e.g. "... (breaking: default output moves totarget/kani/)". - The
pretty/not-a-directory validation is repeated inCargoListArgs,StandaloneListArgsandCommonAutoharnessArgs. A sharedvalidate_list_output(format, output)would keep the three in sync. - #5180 adds
--target-dirafterlistand touches the same files. The two compose, since #5180 feedssession.args.target_dir, but whichever lands second needs a small rebase.
|
Thanks @feliperodri for approving! Since I don't have write access, any chance you could merge this when you get a chance? Happy Thanksgiving! |
|
@hiepnnguyentcu before we merge it...
Is this gonna break any scripts we use for verify-rust-std?
Can you send a commit to tidy up this part? |
|
Hi @feliperodri, This PR won't break verify-rust-std. Its scripts only run It does, however, break scripts outside verify-rust-std that run I validated verify-rust-std against this branch (
About the follow-ups, I am planning to raise two more PRs for the below:
If we prefer to move written by me, polished via Claude Opus 5.5 |
|
Hi @feliperodri, I hope you had a nice Thanksgiving, and no rush at all on this. I wanted to check whether the plan in my last comment works for you. This PR keeps the I also pushed a720dcd for the shared Thank you again for your time! |
a720dcd to
b7ca3cc
Compare

breaking: default output moves to target/kani/
cargo kani list --format json(ormarkdown) writeskani-list.jsoninto the shell's current directory (#5124).This change adds
--output <DIR>tocargo kani list,kani listandautoharness --list, for--format jsonand--format markdown:kani-list.jsonorkani-list.mdintoDIRand creates it if needed.DIRthat exists but is not a directory before the build starts.--format prettysince the command does not produce output file.Without
--output,cargo kani listandcargo kani autoharness --listnow write to<target-dir>/kani/:./kani-list.jsonaftercargo kani listneedtarget/kani/kani-list.jsonor--output ..kani listandkani list --stdhave no cargo target directory and keep the current directory, so verify-rust-std'srun-kani.shis not affected.Testing
cargo_list_outputrunscargo kani listfromsrc/, with--target-dir, and with--outputfor both formats. It fails on anykani-list.*in the package root orsrc/.cargo_list_jsonandcargo_list_mdnow read fromtarget/kani/. Thekani_list_*tests pass unchanged.--outputchecks and the standalone default.cargo kani autoharness --listandkani autoharness --listby hand, with and without--output, plus the error cases and plaincargo kaniandkaniverification.AI coding tools helped write this change and this description.
Resolves #5124
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses.