Skip to content

Commit 5ffe690

Browse files
authored
Merge pull request rust-bitcoin#86 from tcharding/03-10-verify-quiet
verify: Add `--quiet` flag
2 parents 33f72b5 + 32c285a commit 5ffe690

File tree

1 file changed

+21
-15
lines changed

1 file changed

+21
-15
lines changed

verify/src/main.rs

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,18 @@ fn main() -> Result<()> {
3030
.args([
3131
arg!([version] "Verify specific version of Core (use \"all\" for all versions)").required(true),
3232
arg!(-t --tests <TEST_OUTPUT> "Optionally check claimed status of tests").required(false),
33+
arg!(-q --quiet ... "Run tests in quiet mode").required(false),
3334
]);
3435

3536
let matches = cmd.clone().get_matches();
3637
let version = matches.get_one::<String>("version").unwrap();
3738
let test_output = matches.get_one::<String>("tests");
39+
let quiet = matches.get_one::<u8>("quiet") == Some(&1);
3840

3941
if version == "all" {
40-
verify_all_versions(test_output)?;
42+
verify_all_versions(test_output, quiet)?;
4143
} else if let Ok(v) = version.parse::<Version>() {
42-
verify_version(v, test_output)?;
44+
verify_version(v, test_output, quiet)?;
4345
} else {
4446
eprint!("Unrecognised version: {} (supported versions:", version);
4547
for version in VERSIONS {
@@ -51,45 +53,49 @@ fn main() -> Result<()> {
5153
Ok(())
5254
}
5355

54-
fn verify_all_versions(test_output: Option<&String>) -> Result<()> {
56+
fn verify_all_versions(test_output: Option<&String>, quiet: bool) -> Result<()> {
5557
for version in VERSIONS {
56-
println!("Verifying for Bitcoin Core version {} ...\n", version);
57-
verify_version(version, test_output)?;
58+
println!("\nVerifying for Bitcoin Core version {} ...", version);
59+
verify_version(version, test_output, quiet)?;
5860
}
5961
Ok(())
6062
}
6163

62-
fn verify_version(version: Version, test_output: Option<&String>) -> Result<()> {
64+
fn verify_version(version: Version, test_output: Option<&String>, quiet: bool) -> Result<()> {
6365
let s = format!("{}::METHOD data", version);
6466
let msg = format!("Checking that the {} list is correct", s);
65-
check(&msg);
67+
check(&msg, quiet);
6668
let correct = verify_correct_methods(version, method::all_methods(version), &s)?;
67-
close(correct);
69+
close(correct, quiet);
6870
if !correct {
6971
process::exit(1);
7072
}
7173

7274
let s = "rustdoc version specific rustdocs";
7375
let msg = format!("Checking that the {} list is correct", s);
74-
check(&msg);
76+
check(&msg, quiet);
7577
let correct = verify_correct_methods(version, versioned::all_methods(version)?, s)?;
76-
close(correct);
78+
close(correct, quiet);
7779
if !correct {
7880
process::exit(1);
7981
}
8082

8183
let msg = "Checking that the status claimed in the version specific rustdocs is correct";
82-
check(msg);
84+
check(msg, quiet);
8385
verify_status(version, test_output)?;
84-
close(correct);
86+
close(correct, quiet);
8587

8688
Ok(())
8789
}
8890

89-
fn check(msg: &str) { println!("{} ... ", msg) }
91+
fn check(msg: &str, quiet: bool) {
92+
if !quiet {
93+
println!("{} ... ", msg);
94+
}
95+
}
9096

91-
fn close(correct: bool) {
92-
if correct {
97+
fn close(correct: bool, quiet: bool) {
98+
if correct && !quiet {
9399
println!("Correct \u{2713} \n");
94100
}
95101
}

0 commit comments

Comments
 (0)