-
Notifications
You must be signed in to change notification settings - Fork 4
Create test report documentation for manual reuse #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kako-jun
merged 4 commits into
main
from
claude/test-report-documentation-01JJiyvFhFVZ4MSFdXevbPrq
Dec 8, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
58a72f7
feat: add trycmd for living documentation tests
claude 1e8018d
refactor: move example docs to docs/examples/
claude 07a9471
feat: add shell completions and man page generation
claude 2b60fca
docs: update README_ja.md with shell completions and man page
claude File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,160 @@ | ||
| use clap::{Arg, Command, ValueHint}; | ||
| use clap_complete::Shell; | ||
| use clap_mangen::Man; | ||
| use std::env; | ||
| use std::fs; | ||
| use std::path::PathBuf; | ||
|
|
||
| fn build_cli() -> Command { | ||
| Command::new("diffx") | ||
| .version(env!("CARGO_PKG_VERSION")) | ||
| .about("A diff tool for structured data") | ||
| .arg( | ||
| Arg::new("FILE1") | ||
| .help("The first input file") | ||
| .value_hint(ValueHint::FilePath), | ||
| ) | ||
| .arg( | ||
| Arg::new("FILE2") | ||
| .help("The second input file") | ||
| .value_hint(ValueHint::FilePath), | ||
| ) | ||
| .arg( | ||
| Arg::new("completions") | ||
| .long("completions") | ||
| .value_name("SHELL") | ||
| .value_parser(clap::value_parser!(Shell)) | ||
| .help("Generate shell completions for the specified shell"), | ||
| ) | ||
| .arg( | ||
| Arg::new("format") | ||
| .short('f') | ||
| .long("format") | ||
| .value_name("FORMAT") | ||
| .help("Input file format (auto-detected if not specified)") | ||
| .value_parser(["json", "yaml", "csv", "toml", "ini", "xml"]), | ||
| ) | ||
| .arg( | ||
| Arg::new("output") | ||
| .short('o') | ||
| .long("output") | ||
| .value_name("OUTPUT") | ||
| .help("Output format"), | ||
| ) | ||
| .arg( | ||
| Arg::new("path") | ||
| .long("path") | ||
| .value_name("PATH") | ||
| .help("Filter by path (only show differences in paths containing this string)"), | ||
| ) | ||
| .arg( | ||
| Arg::new("ignore-keys-regex") | ||
| .long("ignore-keys-regex") | ||
| .value_name("PATTERN") | ||
| .help("Ignore keys matching this regex pattern"), | ||
| ) | ||
| .arg( | ||
| Arg::new("epsilon") | ||
| .long("epsilon") | ||
| .value_name("VALUE") | ||
| .help("Numerical comparison tolerance (for floating point numbers)"), | ||
| ) | ||
| .arg( | ||
| Arg::new("array-id-key") | ||
| .long("array-id-key") | ||
| .value_name("KEY") | ||
| .help("Array comparison by ID key (compare arrays by this field instead of index)"), | ||
| ) | ||
| .arg( | ||
| Arg::new("ignore-whitespace") | ||
| .long("ignore-whitespace") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Ignore whitespace differences"), | ||
| ) | ||
| .arg( | ||
| Arg::new("ignore-case") | ||
| .long("ignore-case") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Ignore case differences"), | ||
| ) | ||
| .arg( | ||
| Arg::new("quiet") | ||
| .short('q') | ||
| .long("quiet") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Suppress normal output; return only exit status"), | ||
| ) | ||
| .arg( | ||
| Arg::new("brief") | ||
| .long("brief") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Report only whether files differ, not the differences"), | ||
| ) | ||
| .arg( | ||
| Arg::new("verbose") | ||
| .short('v') | ||
| .long("verbose") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Show verbose processing information"), | ||
| ) | ||
| .arg( | ||
| Arg::new("no-color") | ||
| .long("no-color") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Disable colored output"), | ||
| ) | ||
| .arg( | ||
| Arg::new("memory-optimization") | ||
| .long("memory-optimization") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Enable memory optimization for large files"), | ||
| ) | ||
| .arg( | ||
| Arg::new("batch-size") | ||
| .long("batch-size") | ||
| .value_name("SIZE") | ||
| .help("Batch size for memory optimization"), | ||
| ) | ||
| .arg( | ||
| Arg::new("show-unchanged") | ||
| .long("show-unchanged") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Show unchanged values as well"), | ||
| ) | ||
| .arg( | ||
| Arg::new("show-types") | ||
| .long("show-types") | ||
| .action(clap::ArgAction::SetTrue) | ||
| .help("Show type information in output"), | ||
| ) | ||
| } | ||
|
|
||
| fn main() { | ||
| // Only generate man page and completions for release builds | ||
| let out_dir = match env::var_os("OUT_DIR") { | ||
| Some(dir) => PathBuf::from(dir), | ||
| None => return, | ||
| }; | ||
|
|
||
| let cmd = build_cli(); | ||
|
|
||
| // Generate man page | ||
| let man_dir = out_dir.join("man"); | ||
| fs::create_dir_all(&man_dir).unwrap(); | ||
|
|
||
| let man = Man::new(cmd.clone()); | ||
| let mut buffer = Vec::new(); | ||
| man.render(&mut buffer).unwrap(); | ||
| fs::write(man_dir.join("diffx.1"), buffer).unwrap(); | ||
|
|
||
| // Generate shell completions | ||
| let completions_dir = out_dir.join("completions"); | ||
| fs::create_dir_all(&completions_dir).unwrap(); | ||
|
|
||
| for shell in [Shell::Bash, Shell::Zsh, Shell::Fish, Shell::PowerShell] { | ||
| let mut cmd = build_cli(); | ||
| clap_complete::generate_to(shell, &mut cmd, "diffx", &completions_dir).unwrap(); | ||
| } | ||
|
|
||
| println!("cargo:rerun-if-changed=build.rs"); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| //! Example-based tests using trycmd | ||
| //! | ||
| //! These tests serve dual purposes: | ||
| //! 1. Automated regression testing | ||
| //! 2. Living documentation that shows real input/output examples | ||
| //! | ||
| //! The Markdown files in `docs/examples/` are the source of truth | ||
| //! for user documentation and are verified by these tests. | ||
|
|
||
| #[test] | ||
| fn cli_examples() { | ||
| trycmd::TestCases::new() | ||
| .case("../docs/examples/*.md") | ||
| .run(); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new build script (diffx-cli/build.rs) now writes man pages and shell completions, and you added build-dependencies to support it (lines 32-35), but Cargo.toml still lacks a
build = "build.rs"entry in the[package]section. Cargo ignores build scripts unless they are declared, so this script never runs and the documented manpage/completion artifacts will never be generated.Useful? React with 👍 / 👎.