Skip to content

Commit a8697c4

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 0d9c160 commit a8697c4

File tree

1 file changed

+26
-44
lines changed

1 file changed

+26
-44
lines changed

src/tools/compiletest/src/header.rs

+26-44
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(IterHeaderCallbackArgs<'_>),
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.
@@ -811,28 +800,42 @@ struct IterHeaderCallbackArgs<'ln> {
811800
line_number: usize,
812801
}
813802

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

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

838841
let comment = if testfile.extension().is_some_and(|e| e == "rs") {
@@ -1164,35 +1167,14 @@ pub fn make_test_description<R: Read>(
11641167
let mut ignore_message = None;
11651168
let mut should_fail = false;
11661169

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

1189-
iter_header_extra(
1172+
iter_header(
11901173
config.mode,
11911174
&config.suite,
11921175
&mut local_poisoned,
11931176
path,
11941177
src,
1195-
extra_directives,
11961178
&mut |IterHeaderCallbackArgs { header_revision, original_line, line: ln, line_number }| {
11971179
if header_revision.is_some() && header_revision != cfg {
11981180
return;

0 commit comments

Comments
 (0)