Skip to content

Commit

Permalink
rust-lang#107307 Adding additional information to "cargo test --list"…
Browse files Browse the repository at this point in the history
… output

attempting to fix ordering issue
  • Loading branch information
parthopdas committed Feb 8, 2023
1 parent 6a13a85 commit 13b0560
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
13 changes: 10 additions & 3 deletions library/test/src/console.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,14 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res
for test in filter_tests(opts, tests).into_iter() {
use crate::TestFn::*;

let TestDescAndFn { desc: TestDesc { name, ignore, location_info, .. }, testfn } = test;
let TestDescAndFn {
desc: TestDesc {
name,
ignore,
#[cfg(not(bootstrap))]
location_info,
..
}, testfn } = test;

let fntype = match testfn {
StaticTestFn(..) | DynTestFn(..) => {
Expand All @@ -165,8 +172,8 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec<TestDescAndFn>) -> io::Res
}
};

writeln!(output, "{name}: {fntype} | {ignore} | {location_info}")?;
st.write_log(|| format!("{fntype} {name} {ignore} {location_info}\n"))?;
writeln!(output, "{name}: {fntype} | {ignore} | <location_info>")?;
st.write_log(|| format!("{fntype} {name} {ignore} <location_info>\n"))?;
}

fn plural(count: u32, s: &str) -> String {
Expand Down
20 changes: 20 additions & 0 deletions library/test/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
name: StaticTestName("1"),
ignore: true,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -76,6 +77,7 @@ fn one_ignored_one_unignored_test() -> Vec<TestDescAndFn> {
name: StaticTestName("2"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -97,6 +99,7 @@ pub fn do_not_run_ignored_tests() {
name: StaticTestName("whatever"),
ignore: true,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -121,6 +124,7 @@ pub fn ignored_tests_result_in_ignored() {
name: StaticTestName("whatever"),
ignore: true,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -147,6 +151,7 @@ fn test_should_panic() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::Yes,
compile_fail: false,
Expand All @@ -173,6 +178,7 @@ fn test_should_panic_good_message() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::YesWithMessage("error message"),
compile_fail: false,
Expand Down Expand Up @@ -204,6 +210,7 @@ fn test_should_panic_bad_message() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::YesWithMessage(expected),
compile_fail: false,
Expand Down Expand Up @@ -239,6 +246,7 @@ fn test_should_panic_non_string_message_type() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::YesWithMessage(expected),
compile_fail: false,
Expand Down Expand Up @@ -268,6 +276,7 @@ fn test_should_panic_but_succeeds() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic,
compile_fail: false,
Expand Down Expand Up @@ -297,6 +306,7 @@ fn report_time_test_template(report_time: bool) -> Option<TestExecTime> {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -335,6 +345,7 @@ fn time_test_failure_template(test_type: TestType) -> TestResult {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -375,6 +386,7 @@ fn typed_test_desc(test_type: TestType) -> TestDesc {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -488,6 +500,7 @@ pub fn exclude_should_panic_option() {
name: StaticTestName("3"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::Yes,
compile_fail: false,
Expand All @@ -513,6 +526,7 @@ pub fn exact_filter_match() {
name: StaticTestName(name),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -605,6 +619,7 @@ fn sample_tests() -> Vec<TestDescAndFn> {
name: DynTestName((*name).clone()),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -735,6 +750,7 @@ pub fn test_bench_no_iter() {
name: StaticTestName("f"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -759,6 +775,7 @@ pub fn test_bench_iter() {
name: StaticTestName("f"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -776,6 +793,7 @@ fn should_sort_failures_before_printing_them() {
name: StaticTestName("a"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand All @@ -787,6 +805,7 @@ fn should_sort_failures_before_printing_them() {
name: StaticTestName("b"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down Expand Up @@ -835,6 +854,7 @@ fn test_dyn_bench_returning_err_fails_when_run_as_test() {
name: StaticTestName("whatever"),
ignore: false,
ignore_message: None,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: ShouldPanic::No,
compile_fail: false,
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/doctest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@ impl Tester for Collector {
},
ignore_message: None,
// compiler failures are test failures
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic: test::ShouldPanic::No,
compile_fail: config.compile_fail,
Expand Down
1 change: 1 addition & 0 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1043,6 +1043,7 @@ pub fn make_test_description<R: Read>(
name,
ignore,
ignore_message,
#[cfg(not(bootstrap))]
location_info: "src\\lib.rs:10:10: 10:20",
should_panic,
compile_fail: false,
Expand Down

0 comments on commit 13b0560

Please sign in to comment.