Skip to content

Commit 8a28292

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 5ae41d1 commit 8a28292

File tree

1 file changed

+21
-39
lines changed

1 file changed

+21
-39
lines changed

src/tools/compiletest/src/header.rs

+21-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(HeaderLine<'_>),
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.
@@ -812,23 +801,37 @@ struct HeaderLine<'ln> {
812801
line_number: usize,
813802
}
814803

815-
fn iter_header_extra(
804+
fn iter_header(
816805
mode: Mode,
817806
suite: &str,
818807
poisoned: &mut bool,
819808
testfile: &Path,
820809
rdr: impl Read,
821-
extra_directives: &[&str],
822810
it: &mut dyn FnMut(HeaderLine<'_>),
823811
) {
824812
if testfile.is_dir() {
825813
return;
826814
}
827815

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

834837
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
@@ -1160,35 +1163,14 @@ pub fn make_test_description<R: Read>(
11601163
let mut ignore_message = None;
11611164
let mut should_fail = false;
11621165

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

1185-
iter_header_extra(
1168+
iter_header(
11861169
config.mode,
11871170
&config.suite,
11881171
&mut local_poisoned,
11891172
path,
11901173
src,
1191-
extra_directives,
11921174
&mut |HeaderLine { header_revision, original_line, directive: ln, line_number }| {
11931175
if header_revision.is_some() && header_revision != cfg {
11941176
return;

0 commit comments

Comments
 (0)