diff options
Diffstat (limited to 'library/test/src')
| -rw-r--r-- | library/test/src/cli.rs | 4 | ||||
| -rw-r--r-- | library/test/src/console.rs | 16 | ||||
| -rw-r--r-- | library/test/src/formatters/junit.rs | 2 | ||||
| -rw-r--r-- | library/test/src/formatters/pretty.rs | 16 | ||||
| -rw-r--r-- | library/test/src/formatters/terse.rs | 14 | ||||
| -rw-r--r-- | library/test/src/helpers/concurrency.rs | 2 | ||||
| -rw-r--r-- | library/test/src/helpers/exit_code.rs | 2 | ||||
| -rw-r--r-- | library/test/src/lib.rs | 12 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/parm.rs | 2 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/parm/tests.rs | 6 | ||||
| -rw-r--r-- | library/test/src/term/terminfo/parser/compiled.rs | 2 | ||||
| -rw-r--r-- | library/test/src/test_result.rs | 2 |
12 files changed, 40 insertions, 40 deletions
diff --git a/library/test/src/cli.rs b/library/test/src/cli.rs index b39701a3d42..000f5fa3f58 100644 --- a/library/test/src/cli.rs +++ b/library/test/src/cli.rs @@ -149,7 +149,7 @@ fn optgroups() -> getopts::Options { } fn usage(binary: &str, options: &getopts::Options) { - let message = format!("Usage: {} [OPTIONS] [FILTERS...]", binary); + let message = format!("Usage: {binary} [OPTIONS] [FILTERS...]"); println!( r#"{usage} @@ -360,7 +360,7 @@ fn get_shuffle_seed(matches: &getopts::Matches, allow_unstable: bool) -> OptPart shuffle_seed = match env::var("RUST_TEST_SHUFFLE_SEED") { Ok(val) => match val.parse::<u64>() { Ok(n) => Some(n), - Err(_) => panic!("RUST_TEST_SHUFFLE_SEED is `{}`, should be a number.", val), + Err(_) => panic!("RUST_TEST_SHUFFLE_SEED is `{val}`, should be a number."), }, Err(_) => None, }; diff --git a/library/test/src/console.rs b/library/test/src/console.rs index 22fcd77dccc..c7e8507113e 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -114,11 +114,11 @@ impl ConsoleTestState { match *result { TestResult::TrOk => "ok".to_owned(), TestResult::TrFailed => "failed".to_owned(), - TestResult::TrFailedMsg(ref msg) => format!("failed: {}", msg), + TestResult::TrFailedMsg(ref msg) => format!("failed: {msg}"), TestResult::TrIgnored => { #[cfg(not(bootstrap))] if let Some(msg) = ignore_message { - format!("ignored, {}", msg) + format!("ignored, {msg}") } else { "ignored".to_owned() } @@ -132,7 +132,7 @@ impl ConsoleTestState { ) })?; if let Some(exec_time) = exec_time { - self.write_log(|| format!(" <{}>", exec_time))?; + self.write_log(|| format!(" <{exec_time}>"))?; } self.write_log(|| "\n") } @@ -171,14 +171,14 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res } }; - writeln!(output, "{}: {}", name, fntype)?; - st.write_log(|| format!("{} {}\n", fntype, name))?; + writeln!(output, "{name}: {fntype}")?; + st.write_log(|| format!("{fntype} {name}\n"))?; } fn plural(count: u32, s: &str) -> String { match count { - 1 => format!("{} {}", 1, s), - n => format!("{} {}s", n, s), + 1 => format!("1 {s}"), + n => format!("{n} {s}s"), } } @@ -218,7 +218,7 @@ fn handle_test_result(st: &mut ConsoleTestState, completed_test: CompletedTest) TestResult::TrFailedMsg(msg) => { st.failed += 1; let mut stdout = stdout; - stdout.extend_from_slice(format!("note: {}", msg).as_bytes()); + stdout.extend_from_slice(format!("note: {msg}").as_bytes()); st.failures.push((test, stdout)); } TestResult::TrTimedFail => { diff --git a/library/test/src/formatters/junit.rs b/library/test/src/formatters/junit.rs index 54e9860ab54..e6fb4f5707b 100644 --- a/library/test/src/formatters/junit.rs +++ b/library/test/src/formatters/junit.rs @@ -97,7 +97,7 @@ impl<T: Write> OutputFormatter for JunitFormatter<T> { test_name, duration.as_secs_f64() ))?; - self.write_message(&*format!("<failure message=\"{}\" type=\"assert\"/>", m))?; + self.write_message(&*format!("<failure message=\"{m}\" type=\"assert\"/>"))?; self.write_message("</testcase>")?; } diff --git a/library/test/src/formatters/pretty.rs b/library/test/src/formatters/pretty.rs index 041df5216d7..f55d390aa56 100644 --- a/library/test/src/formatters/pretty.rs +++ b/library/test/src/formatters/pretty.rs @@ -96,7 +96,7 @@ impl<T: Write> PrettyFormatter<T> { exec_time: Option<&time::TestExecTime>, ) -> io::Result<()> { if let (Some(opts), Some(time)) = (self.time_options, exec_time) { - let time_str = format!(" <{}>", time); + let time_str = format!(" <{time}>"); let color = if self.use_color { if opts.is_critical(desc, time) { @@ -124,7 +124,7 @@ impl<T: Write> PrettyFormatter<T> { inputs: &Vec<(TestDesc, Vec<u8>)>, results_type: &str, ) -> io::Result<()> { - let results_out_str = format!("\n{}:\n", results_type); + let results_out_str = format!("\n{results_type}:\n"); self.write_plain(&results_out_str)?; @@ -147,7 +147,7 @@ impl<T: Write> PrettyFormatter<T> { self.write_plain(&results_out_str)?; results.sort(); for name in &results { - self.write_plain(&format!(" {}\n", name))?; + self.write_plain(&format!(" {name}\n"))?; } Ok(()) } @@ -167,9 +167,9 @@ impl<T: Write> PrettyFormatter<T> { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + self.write_plain(&format!("test {name} - {test_mode} ... "))?; } else { - self.write_plain(&format!("test {} ... ", name))?; + self.write_plain(&format!("test {name} ... "))?; } Ok(()) @@ -180,11 +180,11 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> { fn write_run_start(&mut self, test_count: usize, shuffle_seed: Option<u64>) -> io::Result<()> { let noun = if test_count != 1 { "tests" } else { "test" }; let shuffle_seed_msg = if let Some(shuffle_seed) = shuffle_seed { - format!(" (shuffle seed: {})", shuffle_seed) + format!(" (shuffle seed: {shuffle_seed})") } else { String::new() }; - self.write_plain(&format!("\nrunning {} {}{}\n", test_count, noun, shuffle_seed_msg)) + self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -266,7 +266,7 @@ impl<T: Write> OutputFormatter for PrettyFormatter<T> { self.write_plain(&s)?; if let Some(ref exec_time) = state.exec_time { - let time_str = format!("; finished in {}", exec_time); + let time_str = format!("; finished in {exec_time}"); self.write_plain(&time_str)?; } diff --git a/library/test/src/formatters/terse.rs b/library/test/src/formatters/terse.rs index 12aca7cd9a4..fb40f86b42e 100644 --- a/library/test/src/formatters/terse.rs +++ b/library/test/src/formatters/terse.rs @@ -122,7 +122,7 @@ impl<T: Write> TerseFormatter<T> { self.write_plain("\nsuccesses:\n")?; successes.sort(); for name in &successes { - self.write_plain(&format!(" {}\n", name))?; + self.write_plain(&format!(" {name}\n"))?; } Ok(()) } @@ -148,7 +148,7 @@ impl<T: Write> TerseFormatter<T> { self.write_plain("\nfailures:\n")?; failures.sort(); for name in &failures { - self.write_plain(&format!(" {}\n", name))?; + self.write_plain(&format!(" {name}\n"))?; } Ok(()) } @@ -156,9 +156,9 @@ impl<T: Write> TerseFormatter<T> { fn write_test_name(&mut self, desc: &TestDesc) -> io::Result<()> { let name = desc.padded_name(self.max_name_len, desc.name.padding()); if let Some(test_mode) = desc.test_mode() { - self.write_plain(&format!("test {} - {} ... ", name, test_mode))?; + self.write_plain(&format!("test {name} - {test_mode} ... "))?; } else { - self.write_plain(&format!("test {} ... ", name))?; + self.write_plain(&format!("test {name} ... "))?; } Ok(()) @@ -170,11 +170,11 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> { self.total_test_count = test_count; let noun = if test_count != 1 { "tests" } else { "test" }; let shuffle_seed_msg = if let Some(shuffle_seed) = shuffle_seed { - format!(" (shuffle seed: {})", shuffle_seed) + format!(" (shuffle seed: {shuffle_seed})") } else { String::new() }; - self.write_plain(&format!("\nrunning {} {}{}\n", test_count, noun, shuffle_seed_msg)) + self.write_plain(&format!("\nrunning {test_count} {noun}{shuffle_seed_msg}\n")) } fn write_test_start(&mut self, desc: &TestDesc) -> io::Result<()> { @@ -247,7 +247,7 @@ impl<T: Write> OutputFormatter for TerseFormatter<T> { self.write_plain(&s)?; if let Some(ref exec_time) = state.exec_time { - let time_str = format!("; finished in {}", exec_time); + let time_str = format!("; finished in {exec_time}"); self.write_plain(&time_str)?; } diff --git a/library/test/src/helpers/concurrency.rs b/library/test/src/helpers/concurrency.rs index e25f524ec05..eb211157371 100644 --- a/library/test/src/helpers/concurrency.rs +++ b/library/test/src/helpers/concurrency.rs @@ -6,7 +6,7 @@ pub fn get_concurrency() -> usize { if let Ok(value) = env::var("RUST_TEST_THREADS") { match value.parse::<NonZeroUsize>().ok() { Some(n) => n.get(), - _ => panic!("RUST_TEST_THREADS is `{}`, should be a positive integer.", value), + _ => panic!("RUST_TEST_THREADS is `{value}`, should be a positive integer."), } } else { thread::available_parallelism().map(|n| n.get()).unwrap_or(1) diff --git a/library/test/src/helpers/exit_code.rs b/library/test/src/helpers/exit_code.rs index 50bb260762a..f762f88819d 100644 --- a/library/test/src/helpers/exit_code.rs +++ b/library/test/src/helpers/exit_code.rs @@ -13,7 +13,7 @@ pub fn get_exit_code(status: ExitStatus) -> Result<i32, String> { match status.code() { Some(code) => Ok(code), None => match status.signal() { - Some(signal) => Err(format!("child process exited with signal {}", signal)), + Some(signal) => Err(format!("child process exited with signal {signal}")), None => Err("child process exited with unknown signal".into()), }, } diff --git a/library/test/src/lib.rs b/library/test/src/lib.rs index 8fc2b4ed748..088e3a23ea4 100644 --- a/library/test/src/lib.rs +++ b/library/test/src/lib.rs @@ -99,7 +99,7 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn>, options: Option<Opt let mut opts = match cli::parse_opts(args) { Some(Ok(o)) => o, Some(Err(msg)) => { - eprintln!("error: {}", msg); + eprintln!("error: {msg}"); process::exit(ERROR_EXIT_CODE); } None => return, @@ -109,7 +109,7 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn>, options: Option<Opt } if opts.list { if let Err(e) = console::list_tests_console(&opts, tests) { - eprintln!("error: io error when listing tests: {:?}", e); + eprintln!("error: io error when listing tests: {e:?}"); process::exit(ERROR_EXIT_CODE); } } else { @@ -117,7 +117,7 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn>, options: Option<Opt Ok(true) => {} Ok(false) => process::exit(ERROR_EXIT_CODE), Err(e) => { - eprintln!("error: io error when listing tests: {:?}", e); + eprintln!("error: io error when listing tests: {e:?}"); process::exit(ERROR_EXIT_CODE); } } @@ -153,7 +153,7 @@ pub fn test_main_static_abort(tests: &[&TestDescAndFn]) { .filter(|test| test.desc.name.as_slice() == name) .map(make_owned_test) .next() - .unwrap_or_else(|| panic!("couldn't find a test with the provided name '{}'", name)); + .unwrap_or_else(|| panic!("couldn't find a test with the provided name '{name}'")); let TestDescAndFn { desc, testfn } = test; let testfn = match testfn { StaticTestFn(f) => f, @@ -524,7 +524,7 @@ pub fn run_test( Arc::get_mut(&mut runtest).unwrap().get_mut().unwrap().take().unwrap()(); None } - Err(e) => panic!("failed to spawn thread to run test: {}", e), + Err(e) => panic!("failed to spawn thread to run test: {e}"), } } else { runtest(); @@ -678,7 +678,7 @@ fn run_test_in_spawned_subprocess(desc: TestDesc, testfn: Box<dyn FnOnce() + Sen // We don't support serializing TrFailedMsg, so just // print the message out to stderr. if let TrFailedMsg(msg) = &test_result { - eprintln!("{}", msg); + eprintln!("{msg}"); } if let Some(info) = panic_info { diff --git a/library/test/src/term/terminfo/parm.rs b/library/test/src/term/terminfo/parm.rs index 0d37eb7359d..0756c8374aa 100644 --- a/library/test/src/term/terminfo/parm.rs +++ b/library/test/src/term/terminfo/parm.rs @@ -268,7 +268,7 @@ pub(crate) fn expand( }, 'e' => state = SeekIfEnd(0), ';' => (), - _ => return Err(format!("unrecognized format option {}", cur)), + _ => return Err(format!("unrecognized format option {cur}")), } } PushParam => { diff --git a/library/test/src/term/terminfo/parm/tests.rs b/library/test/src/term/terminfo/parm/tests.rs index 256d1aaf446..c738f3ba04f 100644 --- a/library/test/src/term/terminfo/parm/tests.rs +++ b/library/test/src/term/terminfo/parm/tests.rs @@ -78,15 +78,15 @@ fn test_push_bad_param() { fn test_comparison_ops() { let v = [('<', [1u8, 0u8, 0u8]), ('=', [0u8, 1u8, 0u8]), ('>', [0u8, 0u8, 1u8])]; for &(op, bs) in v.iter() { - let s = format!("%{{1}}%{{2}}%{}%d", op); + let s = format!("%{{1}}%{{2}}%{op}%d"); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[0]]); - let s = format!("%{{1}}%{{1}}%{}%d", op); + let s = format!("%{{1}}%{{1}}%{op}%d"); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[1]]); - let s = format!("%{{2}}%{{1}}%{}%d", op); + let s = format!("%{{2}}%{{1}}%{op}%d"); let res = expand(s.as_bytes(), &[], &mut Variables::new()); assert!(res.is_ok(), "{}", res.unwrap_err()); assert_eq!(res.unwrap(), vec![b'0' + bs[2]]); diff --git a/library/test/src/term/terminfo/parser/compiled.rs b/library/test/src/term/terminfo/parser/compiled.rs index b24f3f8b05e..5d40b7988b5 100644 --- a/library/test/src/term/terminfo/parser/compiled.rs +++ b/library/test/src/term/terminfo/parser/compiled.rs @@ -198,7 +198,7 @@ pub(crate) fn parse(file: &mut dyn io::Read, longnames: bool) -> Result<TermInfo let extended = match magic { 0o0432 => false, 0o01036 => true, - _ => return Err(format!("invalid magic number, found {:o}", magic)), + _ => return Err(format!("invalid magic number, found {magic:o}")), }; // According to the spec, these fields must be >= -1 where -1 means that the feature is not diff --git a/library/test/src/test_result.rs b/library/test/src/test_result.rs index 8c216a1e0e7..7f44d6e3d0f 100644 --- a/library/test/src/test_result.rs +++ b/library/test/src/test_result.rs @@ -89,7 +89,7 @@ pub fn get_result_from_exit_code( let result = match code { TR_OK => TestResult::TrOk, TR_FAILED => TestResult::TrFailed, - _ => TestResult::TrFailedMsg(format!("got unexpected return code {}", code)), + _ => TestResult::TrFailedMsg(format!("got unexpected return code {code}")), }; // If test is already failed (or allowed to fail), do not change the result. |
