-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Convert run-make/coverage-reports
tests to use a custom compiletest mode
#112300
Changes from all commits
d8d09b0
5b51d9c
a32cdee
75d01f8
a42bbd0
22e119b
e0625b4
d05653c
9d2564a
a2c0b38
edd051c
7b4e75b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1319,6 +1319,13 @@ host_test!(RunMakeFullDeps { | |
|
||
default_test!(Assembly { path: "tests/assembly", mode: "assembly", suite: "assembly" }); | ||
|
||
host_test!(RunCoverage { path: "tests/run-coverage", mode: "run-coverage", suite: "run-coverage" }); | ||
host_test!(RunCoverageRustdoc { | ||
path: "tests/run-coverage-rustdoc", | ||
mode: "run-coverage", | ||
suite: "run-coverage-rustdoc" | ||
}); | ||
|
||
Comment on lines
+1322
to
+1328
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not fully clear on the differences between (It should be possible to run coverage tests on cross-compile targets, but the cross-runner would need to be taught how to send back the resulting There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I also don't have strong feelings on the name of the extra suite; I was wavering between (If there are ever other run-coverage tests with extra tool dependencies, it would probably be fine to group them all into one extra suite with a more generic name.) |
||
// For the mir-opt suite we do not use macros, as we need custom behavior when blessing. | ||
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
pub struct MirOpt { | ||
|
@@ -1503,6 +1510,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the | |
|| (mode == "ui" && is_rustdoc) | ||
|| mode == "js-doc-test" | ||
|| mode == "rustdoc-json" | ||
|| suite == "run-coverage-rustdoc" | ||
{ | ||
cmd.arg("--rustdoc-path").arg(builder.rustdoc(compiler)); | ||
} | ||
|
@@ -1516,7 +1524,7 @@ note: if you're sure you want to do this, please open an issue as to why. In the | |
.arg(builder.ensure(tool::JsonDocLint { compiler: json_compiler, target })); | ||
} | ||
|
||
if mode == "run-make" { | ||
if mode == "run-make" || mode == "run-coverage" { | ||
let rust_demangler = builder | ||
.ensure(tool::RustDemangler { | ||
compiler, | ||
|
@@ -1703,17 +1711,21 @@ note: if you're sure you want to do this, please open an issue as to why. In the | |
add_link_lib_path(vec![llvm_libdir.trim().into()], &mut cmd); | ||
} | ||
|
||
// Only pass correct values for these flags for the `run-make` suite as it | ||
// requires that a C++ compiler was configured which isn't always the case. | ||
if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") { | ||
if !builder.config.dry_run() | ||
Zalathar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
&& (matches!(suite, "run-make" | "run-make-fulldeps") || mode == "run-coverage") | ||
{ | ||
// The llvm/bin directory contains many useful cross-platform | ||
// tools. Pass the path to run-make tests so they can use them. | ||
// (The run-coverage tests also need these tools to process | ||
// coverage reports.) | ||
let llvm_bin_path = llvm_config | ||
.parent() | ||
.expect("Expected llvm-config to be contained in directory"); | ||
assert!(llvm_bin_path.is_dir()); | ||
cmd.arg("--llvm-bin-dir").arg(llvm_bin_path); | ||
} | ||
|
||
if !builder.config.dry_run() && matches!(suite, "run-make" | "run-make-fulldeps") { | ||
Comment on lines
+1726
to
+1728
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The new mode/suites don't need LLD, so I've split this off into a separate conditional that only checks for the run-make suites. |
||
// If LLD is available, add it to the PATH | ||
if builder.config.lld_enabled { | ||
let lld_install_root = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -161,7 +161,7 @@ pub struct TestProps { | |
// customized normalization rules | ||
pub normalize_stdout: Vec<(String, String)>, | ||
pub normalize_stderr: Vec<(String, String)>, | ||
pub failure_status: i32, | ||
pub failure_status: Option<i32>, | ||
// For UI tests, allows compiler to exit with arbitrary failure status | ||
pub dont_check_failure_status: bool, | ||
// Whether or not `rustfix` should apply the `CodeSuggestion`s of this test and compile the | ||
|
@@ -257,7 +257,7 @@ impl TestProps { | |
check_test_line_numbers_match: false, | ||
normalize_stdout: vec![], | ||
normalize_stderr: vec![], | ||
failure_status: -1, | ||
failure_status: None, | ||
dont_check_failure_status: false, | ||
run_rustfix: false, | ||
rustfix_only_machine_applicable: false, | ||
|
@@ -428,7 +428,7 @@ impl TestProps { | |
.parse_name_value_directive(ln, FAILURE_STATUS) | ||
.and_then(|code| code.trim().parse::<i32>().ok()) | ||
{ | ||
self.failure_status = code; | ||
self.failure_status = Some(code); | ||
} | ||
|
||
config.set_name_directive( | ||
|
@@ -491,11 +491,8 @@ impl TestProps { | |
}); | ||
} | ||
|
||
if self.failure_status == -1 { | ||
self.failure_status = 1; | ||
} | ||
if self.should_ice { | ||
self.failure_status = 101; | ||
self.failure_status = Some(101); | ||
} | ||
|
||
if config.mode == Mode::Incremental { | ||
|
@@ -615,10 +612,25 @@ pub fn line_directive<'line>( | |
} | ||
|
||
fn iter_header<R: Read>(testfile: &Path, rdr: R, it: &mut dyn FnMut(Option<&str>, &str, usize)) { | ||
iter_header_extra(testfile, rdr, &[], it) | ||
} | ||
|
||
fn iter_header_extra( | ||
testfile: &Path, | ||
rdr: impl Read, | ||
extra_directives: &[&str], | ||
it: &mut dyn FnMut(Option<&str>, &str, usize), | ||
) { | ||
if testfile.is_dir() { | ||
return; | ||
} | ||
|
||
// Process any extra directives supplied by the caller (e.g. because they | ||
// are implied by the test mode), with a dummy line number of 0. | ||
for directive in extra_directives { | ||
it(None, directive, 0); | ||
} | ||
|
||
let comment = if testfile.extension().map(|e| e == "rs") == Some(true) { "//" } else { "#" }; | ||
|
||
let mut rdr = BufReader::new(rdr); | ||
|
@@ -897,7 +909,27 @@ pub fn make_test_description<R: Read>( | |
let mut ignore_message = None; | ||
let mut should_fail = false; | ||
|
||
iter_header(path, src, &mut |revision, ln, line_number| { | ||
let extra_directives: &[&str] = match config.mode { | ||
// The run-coverage tests are treated as having these extra directives, | ||
// without needing to specify them manually in every test file. | ||
// (Some of the comments below have been copied over from | ||
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.) | ||
Mode::RunCoverage => { | ||
&[ | ||
"needs-profiler-support", | ||
// FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works | ||
// properly. Since we only have GCC on the CI ignore the test for now. | ||
"ignore-windows-gnu", | ||
// FIXME(pietroalbini): this test currently does not work on cross-compiled | ||
// targets because remote-test is not capable of sending back the *.profraw | ||
// files generated by the LLVM instrumentation. | ||
"ignore-cross-compile", | ||
Comment on lines
+920
to
+926
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for including these FIXMEs here, that will make it easier to understand in the future when they can be removed! |
||
] | ||
} | ||
_ => &[], | ||
}; | ||
|
||
iter_header_extra(path, src, extra_directives, &mut |revision, ln, line_number| { | ||
if revision.is_some() && revision != cfg { | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I didn't put much thought into the relative ordering of these new suites, so their placement is somewhat arbitrary.