use crate::{
bench::Bencher,
console::OutputLocation,
- options::OutputFormat,
- time::{TimeThreshold, TestTimeOptions},
formatters::PrettyFormatter,
+ options::OutputFormat,
test::{
- filter_tests, parse_opts, run_test, DynTestFn, DynTestName, MetricMap,
- RunIgnored, RunStrategy, ShouldPanic, StaticTestName, TestDesc,
- TestDescAndFn, TestOpts, TrIgnored, TrOk,
+ filter_tests,
+ parse_opts,
+ run_test,
+ DynTestFn,
+ DynTestName,
+ MetricMap,
+ RunIgnored,
+ RunStrategy,
+ ShouldPanic,
+ StaticTestName,
+ TestDesc,
+ TestDescAndFn,
+ TestOpts,
+ TrIgnored,
+ TrOk,
// FIXME (introduced by #65251)
// ShouldPanic, StaticTestName, TestDesc, TestDescAndFn, TestOpts, TestTimeOptions,
// TestType, TrFailedMsg, TrIgnored, TrOk,
},
+ time::{TestTimeOptions, TimeThreshold},
};
use std::any::TypeId;
use std::sync::mpsc::channel;
panic!(1i32);
}
let expected = "foobar";
- let failed_msg = format!(r#"expected panic with string value,
+ let failed_msg = format!(
+ r#"expected panic with string value,
found non-string value: `{:?}`
- expected substring: `"foobar"`"#, TypeId::of::<i32>());
+ expected substring: `"foobar"`"#,
+ TypeId::of::<i32>()
+ );
let desc = TestDescAndFn {
desc: TestDesc {
name: StaticTestName("whatever"),
},
testfn: DynTestFn(Box::new(f)),
};
- let time_options = if report_time {
- Some(TestTimeOptions::default())
- } else {
- None
- };
+ let time_options = if report_time { Some(TestTimeOptions::default()) } else { None };
- let test_opts = TestOpts {
- time_options,
- ..TestOpts::new()
- };
+ let test_opts = TestOpts { time_options, ..TestOpts::new() };
let (tx, rx) = channel();
run_test(&test_opts, false, desc, RunStrategy::InProcess, tx, Concurrent::No);
let exec_time = rx.recv().unwrap().exec_time;
ignore: false,
should_panic: ShouldPanic::No,
allow_fail: false,
- test_type
+ test_type,
},
testfn: DynTestFn(Box::new(f)),
};
let mut time_options = TestTimeOptions::default();
time_options.error_on_excess = true;
- let test_opts = TestOpts {
- time_options: Some(time_options),
- ..TestOpts::new()
- };
+ let test_opts = TestOpts { time_options: Some(time_options), ..TestOpts::new() };
let (tx, rx) = channel();
run_test(&test_opts, false, desc, RunStrategy::InProcess, tx, Concurrent::No);
let result = rx.recv().unwrap().result;
ignore: false,
should_panic: ShouldPanic::No,
allow_fail: false,
- test_type
+ test_type,
}
}
#[test]
fn parse_ignored_flag() {
- let args = vec![
- "progname".to_string(),
- "filter".to_string(),
- "--ignored".to_string(),
- ];
+ let args = vec!["progname".to_string(), "filter".to_string(), "--ignored".to_string()];
let opts = parse_opts(&args).unwrap().unwrap();
assert_eq!(opts.run_ignored, RunIgnored::Only);
}
#[test]
fn parse_show_output_flag() {
- let args = vec![
- "progname".to_string(),
- "filter".to_string(),
- "--show-output".to_string(),
- ];
+ let args = vec!["progname".to_string(), "filter".to_string(), "--show-output".to_string()];
let opts = parse_opts(&args).unwrap().unwrap();
assert!(opts.options.display_output);
}
.collect()
}
- let substr = filter_tests(
- &TestOpts {
- filter: Some("base".into()),
- ..TestOpts::new()
- },
- tests(),
- );
+ let substr =
+ filter_tests(&TestOpts { filter: Some("base".into()), ..TestOpts::new() }, tests());
assert_eq!(substr.len(), 4);
- let substr = filter_tests(
- &TestOpts {
- filter: Some("bas".into()),
- ..TestOpts::new()
- },
- tests(),
- );
+ let substr = filter_tests(&TestOpts { filter: Some("bas".into()), ..TestOpts::new() }, tests());
assert_eq!(substr.len(), 4);
- let substr = filter_tests(
- &TestOpts {
- filter: Some("::test".into()),
- ..TestOpts::new()
- },
- tests(),
- );
+ let substr =
+ filter_tests(&TestOpts { filter: Some("::test".into()), ..TestOpts::new() }, tests());
assert_eq!(substr.len(), 3);
- let substr = filter_tests(
- &TestOpts {
- filter: Some("base::test".into()),
- ..TestOpts::new()
- },
- tests(),
- );
+ let substr =
+ filter_tests(&TestOpts { filter: Some("base::test".into()), ..TestOpts::new() }, tests());
assert_eq!(substr.len(), 3);
let exact = filter_tests(
- &TestOpts {
- filter: Some("base".into()),
- filter_exact: true,
- ..TestOpts::new()
- },
+ &TestOpts { filter: Some("base".into()), filter_exact: true, ..TestOpts::new() },
tests(),
);
assert_eq!(exact.len(), 1);
let exact = filter_tests(
- &TestOpts {
- filter: Some("bas".into()),
- filter_exact: true,
- ..TestOpts::new()
- },
+ &TestOpts { filter: Some("bas".into()), filter_exact: true, ..TestOpts::new() },
tests(),
);
assert_eq!(exact.len(), 0);
let exact = filter_tests(
- &TestOpts {
- filter: Some("::test".into()),
- filter_exact: true,
- ..TestOpts::new()
- },
+ &TestOpts { filter: Some("::test".into()), filter_exact: true, ..TestOpts::new() },
tests(),
);
assert_eq!(exact.len(), 0);
let exact = filter_tests(
- &TestOpts {
- filter: Some("base::test".into()),
- filter_exact: true,
- ..TestOpts::new()
- },
+ &TestOpts { filter: Some("base::test".into()), filter_exact: true, ..TestOpts::new() },
tests(),
);
assert_eq!(exact.len(), 1);