diff --git a/.gitignore b/.gitignore index e5ca3e503130f..f2e22cc800c05 100644 --- a/.gitignore +++ b/.gitignore @@ -21,6 +21,7 @@ Session.vim .project .favorites.json .settings/ +.vs/ ## Tool .valgrindrc diff --git a/compiler/rustc_builtin_macros/src/test.rs b/compiler/rustc_builtin_macros/src/test.rs index 729ae4071e200..ae9f7ed046af2 100644 --- a/compiler/rustc_builtin_macros/src/test.rs +++ b/compiler/rustc_builtin_macros/src/test.rs @@ -8,7 +8,7 @@ use rustc_errors::Applicability; use rustc_expand::base::*; use rustc_session::Session; use rustc_span::symbol::{sym, Ident, Symbol}; -use rustc_span::Span; +use rustc_span::{FileNameDisplayPreference, Span}; use std::iter; use thin_vec::thin_vec; @@ -280,6 +280,11 @@ pub fn expand_test_or_bench( cx.expr_none(sp) }, ), + // location_info: ::: : + field( + "location_info", + cx.expr_str(sp, item_location_info(cx, &item)), + ), // compile_fail: true | false field("compile_fail", cx.expr_bool(sp, false)), // no_run: true | false @@ -396,6 +401,11 @@ fn should_ignore_message(cx: &ExtCtxt<'_>, i: &ast::Item) -> Option { } } +fn item_location_info(cx: &ExtCtxt<'_>, item: &ast::Item) -> Symbol { + let li = cx.sess.source_map().span_to_string(item.ident.span, FileNameDisplayPreference::Local); + Symbol::intern(&li) +} + fn should_panic(cx: &ExtCtxt<'_>, i: &ast::Item) -> ShouldPanic { match cx.sess.find_by_name(&i.attrs, sym::should_panic) { Some(attr) => { diff --git a/library/test/src/console.rs b/library/test/src/console.rs index 1ee68c8540bcc..91c235a5c75d2 100644 --- a/library/test/src/console.rs +++ b/library/test/src/console.rs @@ -152,7 +152,17 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Res for test in filter_tests(opts, tests).into_iter() { use crate::TestFn::*; - let TestDescAndFn { desc: TestDesc { name, .. }, testfn } = test; + let TestDescAndFn { + desc: + TestDesc { + name, + ignore, + #[cfg(not(bootstrap))] + location_info, + .. + }, + testfn, + } = test; let fntype = match testfn { StaticTestFn(..) | DynTestFn(..) => { @@ -165,8 +175,13 @@ pub fn list_tests_console(opts: &TestOpts, tests: Vec) -> io::Res } }; - writeln!(output, "{name}: {fntype}")?; - st.write_log(|| format!("{fntype} {name}\n"))?; + #[cfg(bootstrap)] + let location_info = "location_info_tbd_during_bootstrap"; + + let state_str = if ignore { "ignored" } else { "active" }; + + writeln!(output, "{name} | {fntype} | {state_str} | {location_info}")?; + st.write_log(|| format!("{fntype} {name} {state_str} {location_info}\n"))?; } fn plural(count: u32, s: &str) -> String { diff --git a/library/test/src/tests.rs b/library/test/src/tests.rs index 44776fb0a316d..bd52502157b14 100644 --- a/library/test/src/tests.rs +++ b/library/test/src/tests.rs @@ -63,6 +63,8 @@ fn one_ignored_one_unignored_test() -> Vec { name: StaticTestName("1"), ignore: true, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -75,6 +77,8 @@ fn one_ignored_one_unignored_test() -> Vec { name: StaticTestName("2"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -95,6 +99,8 @@ pub fn do_not_run_ignored_tests() { name: StaticTestName("whatever"), ignore: true, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -118,6 +124,8 @@ pub fn ignored_tests_result_in_ignored() { name: StaticTestName("whatever"), ignore: true, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -143,6 +151,8 @@ fn test_should_panic() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::Yes, compile_fail: false, no_run: false, @@ -168,6 +178,8 @@ fn test_should_panic_good_message() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::YesWithMessage("error message"), compile_fail: false, no_run: false, @@ -198,6 +210,8 @@ fn test_should_panic_bad_message() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::YesWithMessage(expected), compile_fail: false, no_run: false, @@ -232,6 +246,8 @@ fn test_should_panic_non_string_message_type() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::YesWithMessage(expected), compile_fail: false, no_run: false, @@ -260,6 +276,8 @@ fn test_should_panic_but_succeeds() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic, compile_fail: false, no_run: false, @@ -288,6 +306,8 @@ fn report_time_test_template(report_time: bool) -> Option { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -325,6 +345,8 @@ fn time_test_failure_template(test_type: TestType) -> TestResult { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -364,6 +386,8 @@ fn typed_test_desc(test_type: TestType) -> TestDesc { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -476,6 +500,8 @@ pub fn exclude_should_panic_option() { name: StaticTestName("3"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::Yes, compile_fail: false, no_run: false, @@ -500,6 +526,8 @@ pub fn exact_filter_match() { name: StaticTestName(name), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -591,6 +619,8 @@ fn sample_tests() -> Vec { name: DynTestName((*name).clone()), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -720,6 +750,8 @@ pub fn test_bench_no_iter() { name: StaticTestName("f"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -743,6 +775,8 @@ pub fn test_bench_iter() { name: StaticTestName("f"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -759,6 +793,8 @@ fn should_sort_failures_before_printing_them() { name: StaticTestName("a"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -769,6 +805,8 @@ fn should_sort_failures_before_printing_them() { name: StaticTestName("b"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, @@ -816,6 +854,8 @@ fn test_dyn_bench_returning_err_fails_when_run_as_test() { name: StaticTestName("whatever"), ignore: false, ignore_message: None, + #[cfg(not(bootstrap))] + location_info: "", should_panic: ShouldPanic::No, compile_fail: false, no_run: false, diff --git a/library/test/src/types.rs b/library/test/src/types.rs index 6f2e033095a37..194cdcb65fdb0 100644 --- a/library/test/src/types.rs +++ b/library/test/src/types.rs @@ -119,6 +119,8 @@ pub struct TestDesc { pub name: TestName, pub ignore: bool, pub ignore_message: Option<&'static str>, + #[cfg(not(bootstrap))] + pub location_info: &'static str, pub should_panic: options::ShouldPanic, pub compile_fail: bool, pub no_run: bool, diff --git a/src/librustdoc/doctest.rs b/src/librustdoc/doctest.rs index 37a1005cba1fc..05d44716b22b2 100644 --- a/src/librustdoc/doctest.rs +++ b/src/librustdoc/doctest.rs @@ -1063,6 +1063,8 @@ impl Tester for Collector { }, ignore_message: None, // compiler failures are test failures + #[cfg(not(bootstrap))] + location_info: "", should_panic: test::ShouldPanic::No, compile_fail: config.compile_fail, no_run, diff --git a/src/tools/compiletest/src/header.rs b/src/tools/compiletest/src/header.rs index 45fd87bea9bb5..238bfa2506c15 100644 --- a/src/tools/compiletest/src/header.rs +++ b/src/tools/compiletest/src/header.rs @@ -1043,6 +1043,8 @@ pub fn make_test_description( name, ignore, ignore_message, + #[cfg(not(bootstrap))] + location_info: "", should_panic, compile_fail: false, no_run: false, diff --git a/tests/pretty/tests-are-sorted.pp b/tests/pretty/tests-are-sorted.pp index 15dcd4ed97df4..58203dc6e59cd 100644 --- a/tests/pretty/tests-are-sorted.pp +++ b/tests/pretty/tests-are-sorted.pp @@ -18,6 +18,7 @@ name: test::StaticTestName("m_test"), ignore: false, ignore_message: ::core::option::Option::None, + location_info: "/checkout/tests/pretty/tests-are-sorted.rs:7:4: 7:10", compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -36,6 +37,7 @@ name: test::StaticTestName("z_test"), ignore: false, ignore_message: ::core::option::Option::None, + location_info: "/checkout/tests/pretty/tests-are-sorted.rs:10:4: 10:10", compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No, @@ -54,6 +56,7 @@ name: test::StaticTestName("a_test"), ignore: false, ignore_message: ::core::option::Option::None, + location_info: "/checkout/tests/pretty/tests-are-sorted.rs:13:4: 13:10", compile_fail: false, no_run: false, should_panic: test::ShouldPanic::No,