Skip to content

Commit

Permalink
Move the extra directives for Mode::CoverageRun into iter_header
Browse files Browse the repository at this point in the history
When these extra directives were ported over as part of rust-lang#112300, it made sense
to introduce `iter_header_extra` and pass them in as an extra argument.

But now that rust-lang#120881 has added a `mode` parameter to `iter_header` for its own
purposes, it's slightly simpler to move the coverage special-case code directly
into `iter_header` as well. This lets us get rid of `iter_header_extra`.
  • Loading branch information
Zalathar committed Feb 17, 2024
1 parent dfdbe30 commit f5fe649
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,17 +671,6 @@ pub fn line_directive<'line>(
}
}

fn iter_header<R: Read>(
mode: Mode,
suite: &str,
poisoned: &mut bool,
testfile: &Path,
rdr: R,
it: &mut dyn FnMut(Option<&str>, &str, &str, usize),
) {
iter_header_extra(mode, suite, poisoned, testfile, rdr, &[], it)
}

/// This is generated by collecting directives from ui tests and then extracting their directive
/// names. This is **not** an exhaustive list of all possible directives. Instead, this is a
/// best-effort approximation for diagnostics.
Expand Down Expand Up @@ -800,23 +789,38 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
"unset-rustc-env",
];

fn iter_header_extra(
fn iter_header(
mode: Mode,
suite: &str,
poisoned: &mut bool,
testfile: &Path,
rdr: impl Read,
extra_directives: &[&str],
// Callback arguments: (revision_name, original_line, line, line_number)
it: &mut dyn FnMut(Option<&str>, &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, directive, 0);
// Coverage tests in coverage-run mode always have these extra directives,
// without needing to specify them manually in every test file.
// (Some of the comments below have been copied over from the old
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
if mode == Mode::CoverageRun {
let extra_directives: &[&str] = &[
"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",
];
// Process the extra implied directives, with a dummy line number of 0.
for directive in extra_directives {
it(None, "", directive, 0);
}
}

let comment = if testfile.extension().is_some_and(|e| e == "rs") {
Expand Down Expand Up @@ -1148,35 +1152,14 @@ pub fn make_test_description<R: Read>(
let mut ignore_message = None;
let mut should_fail = false;

let extra_directives: &[&str] = match config.mode {
// The coverage-run 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::CoverageRun => {
&[
"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",
]
}
_ => &[],
};

let mut local_poisoned = false;

iter_header_extra(
iter_header(
config.mode,
&config.suite,
&mut local_poisoned,
path,
src,
extra_directives,
&mut |revision, og_ln, ln, line_number| {
if revision.is_some() && revision != cfg {
return;
Expand Down

0 comments on commit f5fe649

Please sign in to comment.