From: Manish Goregaokar Date: Thu, 11 Jan 2018 07:26:43 +0000 (+0530) Subject: Explicitly mention testname argument for cargo test/bench X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~3^2~44^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=c3a7db176490cd33f388872418ada516d89e353c;p=cargo.git Explicitly mention testname argument for cargo test/bench --- diff --git a/src/bin/bench.rs b/src/bin/bench.rs index eaf4c0d6b..e00002ebe 100644 --- a/src/bin/bench.rs +++ b/src/bin/bench.rs @@ -37,15 +37,18 @@ pub struct Options { flag_exclude: Vec, #[serde(rename = "flag_Z")] flag_z: Vec, + #[serde(rename = "arg_BENCHNAME")] + arg_benchname: Option, } pub const USAGE: &'static str = " Execute all benchmarks of a local package Usage: - cargo bench [options] [--] [...] + cargo bench [options] [BENCHNAME] [--] [...] Options: + BENCHNAME If specified, only run benches containing this string in their names -h, --help Print this message --lib Benchmark only this package's library --bin NAME ... Benchmark only the specified binary @@ -95,7 +98,7 @@ not affect how many jobs are used when running the benchmarks. Compilation can be customized with the `bench` profile in the manifest. "; -pub fn execute(options: Options, config: &mut Config) -> CliResult { +pub fn execute(mut options: Options, config: &mut Config) -> CliResult { debug!("executing; cmd=cargo-bench; args={:?}", env::args().collect::>()); @@ -139,6 +142,10 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { }, }; + if let Some(test) = options.arg_benchname.take() { + options.arg_args.insert(0, test); + } + let err = ops::run_benches(&ws, &ops, &options.arg_args)?; match err { None => Ok(()), diff --git a/src/bin/test.rs b/src/bin/test.rs index c4c2bac3d..242f1ebb2 100644 --- a/src/bin/test.rs +++ b/src/bin/test.rs @@ -39,15 +39,18 @@ pub struct Options { flag_exclude: Vec, #[serde(rename = "flag_Z")] flag_z: Vec, + #[serde(rename = "arg_TESTNAME")] + arg_testname: Option, } pub const USAGE: &'static str = " Execute all unit and integration tests of a local package Usage: - cargo test [options] [--] [...] + cargo test [options] [TESTNAME] [--] [...] Options: + TESTNAME If specified, only run tests containing this string in their names -h, --help Print this message --lib Test only this package's library --doc Test only this library's documentation @@ -116,7 +119,7 @@ To get the list of all options available for the test binaries use this: cargo test -- --help "; -pub fn execute(options: Options, config: &mut Config) -> CliResult { +pub fn execute(mut options: Options, config: &mut Config) -> CliResult { debug!("executing; cmd=cargo-test; args={:?}", env::args().collect::>()); @@ -172,6 +175,12 @@ pub fn execute(options: Options, config: &mut Config) -> CliResult { }, }; + // TESTNAME is actually an argument of the test binary, but it's + // important so we explicitly mention it and reconfigure + if let Some(test) = options.arg_testname.take() { + options.arg_args.insert(0, test); + } + let err = ops::run_tests(&ws, &ops, &options.arg_args)?; match err { None => Ok(()),