Skip to content

Commit f5fe649

Browse files
committed
Move the extra directives for Mode::CoverageRun into iter_header
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`.
1 parent dfdbe30 commit f5fe649

File tree

1 file changed

+22
-39
lines changed

1 file changed

+22
-39
lines changed

src/tools/compiletest/src/header.rs

+22-39
Original file line numberDiff line numberDiff line change
@@ -671,17 +671,6 @@ pub fn line_directive<'line>(
671671
}
672672
}
673673

674-
fn iter_header<R: Read>(
675-
mode: Mode,
676-
suite: &str,
677-
poisoned: &mut bool,
678-
testfile: &Path,
679-
rdr: R,
680-
it: &mut dyn FnMut(Option<&str>, &str, &str, usize),
681-
) {
682-
iter_header_extra(mode, suite, poisoned, testfile, rdr, &[], it)
683-
}
684-
685674
/// This is generated by collecting directives from ui tests and then extracting their directive
686675
/// names. This is **not** an exhaustive list of all possible directives. Instead, this is a
687676
/// best-effort approximation for diagnostics.
@@ -800,23 +789,38 @@ const DIAGNOSTICS_DIRECTIVE_NAMES: &[&str] = &[
800789
"unset-rustc-env",
801790
];
802791

803-
fn iter_header_extra(
792+
fn iter_header(
804793
mode: Mode,
805794
suite: &str,
806795
poisoned: &mut bool,
807796
testfile: &Path,
808797
rdr: impl Read,
809-
extra_directives: &[&str],
798+
// Callback arguments: (revision_name, original_line, line, line_number)
810799
it: &mut dyn FnMut(Option<&str>, &str, &str, usize),
811800
) {
812801
if testfile.is_dir() {
813802
return;
814803
}
815804

816-
// Process any extra directives supplied by the caller (e.g. because they
817-
// are implied by the test mode), with a dummy line number of 0.
818-
for directive in extra_directives {
819-
it(None, directive, directive, 0);
805+
// Coverage tests in coverage-run mode always have these extra directives,
806+
// without needing to specify them manually in every test file.
807+
// (Some of the comments below have been copied over from the old
808+
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
809+
if mode == Mode::CoverageRun {
810+
let extra_directives: &[&str] = &[
811+
"needs-profiler-support",
812+
// FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
813+
// properly. Since we only have GCC on the CI ignore the test for now.
814+
"ignore-windows-gnu",
815+
// FIXME(pietroalbini): this test currently does not work on cross-compiled
816+
// targets because remote-test is not capable of sending back the *.profraw
817+
// files generated by the LLVM instrumentation.
818+
"ignore-cross-compile",
819+
];
820+
// Process the extra implied directives, with a dummy line number of 0.
821+
for directive in extra_directives {
822+
it(None, "", directive, 0);
823+
}
820824
}
821825

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

1151-
let extra_directives: &[&str] = match config.mode {
1152-
// The coverage-run tests are treated as having these extra directives,
1153-
// without needing to specify them manually in every test file.
1154-
// (Some of the comments below have been copied over from
1155-
// `tests/run-make/coverage-reports/Makefile`, which no longer exists.)
1156-
Mode::CoverageRun => {
1157-
&[
1158-
"needs-profiler-support",
1159-
// FIXME(mati865): MinGW GCC miscompiles compiler-rt profiling library but with Clang it works
1160-
// properly. Since we only have GCC on the CI ignore the test for now.
1161-
"ignore-windows-gnu",
1162-
// FIXME(pietroalbini): this test currently does not work on cross-compiled
1163-
// targets because remote-test is not capable of sending back the *.profraw
1164-
// files generated by the LLVM instrumentation.
1165-
"ignore-cross-compile",
1166-
]
1167-
}
1168-
_ => &[],
1169-
};
1170-
11711155
let mut local_poisoned = false;
11721156

1173-
iter_header_extra(
1157+
iter_header(
11741158
config.mode,
11751159
&config.suite,
11761160
&mut local_poisoned,
11771161
path,
11781162
src,
1179-
extra_directives,
11801163
&mut |revision, og_ln, ln, line_number| {
11811164
if revision.is_some() && revision != cfg {
11821165
return;

0 commit comments

Comments
 (0)