Skip to content
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

compiletest: Remove the one thing that was checking a directive's original_line #131585

Merged
merged 2 commits into from
Oct 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 10 additions & 29 deletions src/tools/compiletest/src/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ impl EarlyProps {
&mut poisoned,
testfile,
rdr,
&mut |HeaderLine { directive: ln, .. }| {
&mut |DirectiveLine { directive: ln, .. }| {
parse_and_update_aux(config, ln, &mut props.aux);
config.parse_and_update_revisions(ln, &mut props.revisions);
},
Expand Down Expand Up @@ -344,7 +344,7 @@ impl TestProps {
&mut poisoned,
testfile,
file,
&mut |HeaderLine { header_revision, directive: ln, .. }| {
&mut |DirectiveLine { header_revision, directive: ln, .. }| {
if header_revision.is_some() && header_revision != test_revision {
return;
}
Expand Down Expand Up @@ -680,7 +680,7 @@ impl TestProps {

/// Extract an `(Option<line_revision>, directive)` directive from a line if comment is present.
///
/// See [`HeaderLine`] for a diagram.
/// See [`DirectiveLine`] for a diagram.
pub fn line_directive<'line>(
comment: &str,
original_line: &'line str,
Expand Down Expand Up @@ -738,17 +738,13 @@ const KNOWN_JSONDOCCK_DIRECTIVE_NAMES: &[&str] =
/// ```text
/// //@ compile-flags: -O
/// ^^^^^^^^^^^^^^^^^ directive
/// ^^^^^^^^^^^^^^^^^^^^^ original_line
///
/// //@ [foo] compile-flags: -O
/// ^^^ header_revision
/// ^^^^^^^^^^^^^^^^^ directive
/// ^^^^^^^^^^^^^^^^^^^^^^^^^^^ original_line
/// ```
struct HeaderLine<'ln> {
struct DirectiveLine<'ln> {
line_number: usize,
/// Raw line from the test file, including comment prefix and any revision.
original_line: &'ln str,
/// Some header directives start with a revision name in square brackets
/// (e.g. `[foo]`), and only apply to that revision of the test.
/// If present, this field contains the revision name (e.g. `foo`).
Expand Down Expand Up @@ -803,7 +799,7 @@ fn iter_header(
poisoned: &mut bool,
testfile: &Path,
rdr: impl Read,
it: &mut dyn FnMut(HeaderLine<'_>),
it: &mut dyn FnMut(DirectiveLine<'_>),
) {
if testfile.is_dir() {
return;
Expand All @@ -824,7 +820,7 @@ fn iter_header(
];
// Process the extra implied directives, with a dummy line number of 0.
for directive in extra_directives {
it(HeaderLine { line_number: 0, original_line: "", header_revision: None, directive });
it(DirectiveLine { line_number: 0, header_revision: None, directive });
}
}

Expand All @@ -841,11 +837,6 @@ fn iter_header(
if rdr.read_line(&mut ln).unwrap() == 0 {
break;
}

// Assume that any directives will be found before the first
// module or function. This doesn't seem to be an optimization
// with a warm page cache. Maybe with a cold one.
let original_line = &ln;
let ln = ln.trim();

// Assume that any directives will be found before the first module or function. This
Expand Down Expand Up @@ -897,9 +888,8 @@ fn iter_header(
}
}

it(HeaderLine {
it(DirectiveLine {
line_number,
original_line,
header_revision,
directive: non_revisioned_directive_line,
});
Expand Down Expand Up @@ -1286,13 +1276,14 @@ pub fn make_test_description<R: Read>(

let mut local_poisoned = false;

// Scan through the test file to handle `ignore-*`, `only-*`, and `needs-*` directives.
iter_header(
config.mode,
&config.suite,
&mut local_poisoned,
path,
src,
&mut |HeaderLine { header_revision, original_line, directive: ln, line_number }| {
&mut |DirectiveLine { header_revision, directive: ln, line_number }| {
if header_revision.is_some() && header_revision != test_revision {
return;
}
Expand All @@ -1317,17 +1308,7 @@ pub fn make_test_description<R: Read>(
};
}

if let Some((_, post)) = original_line.trim_start().split_once("//") {
let post = post.trim_start();
if post.starts_with("ignore-tidy") {
// Not handled by compiletest.
} else {
decision!(cfg::handle_ignore(config, ln));
}
} else {
decision!(cfg::handle_ignore(config, ln));
}

decision!(cfg::handle_ignore(config, ln));
decision!(cfg::handle_only(config, ln));
decision!(needs::handle_needs(&cache.needs, config, ln));
decision!(ignore_llvm(config, ln));
Expand Down
Loading