Skip to content

Commit 1a70f8d

Browse files
committed
Auto merge of #156561 - jieyouxu:rollup-l3kXdVY, r=jieyouxu
Rollup of 2 pull requests Successful merges: - #156450 (compiletest: Enforce that directives are consistently used with or without a colon) - #156531 (compiletest: Rename `//@ ignore-pass` to `//@ no-pass-override`)
2 parents c85af1c + 76d07a6 commit 1a70f8d

52 files changed

Lines changed: 1207 additions & 1210 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/doc/rustc-dev-guide/src/tests/directives.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ See [Controlling pass/fail expectations](ui.md#controlling-passfail-expectations
7878
| `run-fail` | Program must exit with code `1..=127` | `ui` | N/A |
7979
| `run-crash` | Program must crash | `ui` | N/A |
8080
| `run-fail-or-crash` | Program must `run-fail` or `run-crash` | `ui` | N/A |
81-
| `ignore-pass` | Ignore `--pass` flag | `ui` | N/A |
81+
| `no-pass-override` | Ignore `--pass` flag | `ui` | N/A |
8282
| `dont-check-failure-status` | Don't check exact failure status (i.e. `1`) | `ui`, `incremental` | N/A |
8383
| `failure-status` | On failure, the compiler must exit with this status code. To expect an ICE, use `//@ failure-status: 101`. | `ui`, `incremental` | Any `u16` |
8484
| `should-fail` | Compiletest self-test | All | N/A |

src/doc/rustc-dev-guide/src/tests/running.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ There are a few options for running tests:
202202

203203
Pass UI tests now have three modes, `check-pass`, `build-pass` and `run-pass`.
204204
When `--pass $mode` is passed, these tests will be forced to run under the given
205-
`$mode` unless the directive `//@ ignore-pass` exists in the test file.
205+
`$mode` unless the directive `//@ no-pass-override` exists in the test file.
206206
For example, you can run all the tests in `tests/ui` as `check-pass`:
207207

208208
```text

src/doc/rustc-dev-guide/src/tests/ui.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ Using `--pass check` can run the UI
492492
test suite much faster (roughly twice as fast on my system), though obviously
493493
not exercising as much.
494494

495-
The `ignore-pass` directive can be used to ignore the `--pass` CLI flag if the
495+
The `no-pass-override` directive can be used to ignore the `--pass` CLI flag if the
496496
test won't work properly with that override.
497497

498498

src/tools/compiletest/src/directives.rs

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub(crate) struct TestProps {
171171
/// None for non-UI tests, and for auxiliary crates used by UI tests.
172172
pub(crate) pass_fail_mode: Option<PassFailMode>,
173173
// Ignore `--pass` overrides from the command line for this test.
174-
pub(crate) ignore_pass: bool,
174+
pub(crate) no_pass_override: bool,
175175
// rustdoc will test the output of the `--test` option
176176
pub(crate) check_test_line_numbers_match: bool,
177177
// customized normalization rules
@@ -244,7 +244,6 @@ mod directives {
244244
pub(crate) const UNSET_RUSTC_ENV: &str = "unset-rustc-env";
245245
pub(crate) const FORBID_OUTPUT: &str = "forbid-output";
246246
pub(crate) const CHECK_TEST_LINE_NUMBERS_MATCH: &str = "check-test-line-numbers-match";
247-
pub(crate) const IGNORE_PASS: &str = "ignore-pass";
248247
pub(crate) const FAILURE_STATUS: &str = "failure-status";
249248
pub(crate) const DONT_CHECK_FAILURE_STATUS: &str = "dont-check-failure-status";
250249
pub(crate) const RUN_RUSTFIX: &str = "run-rustfix";
@@ -298,7 +297,7 @@ impl TestProps {
298297
incremental: false,
299298
known_bug: false,
300299
pass_fail_mode: None,
301-
ignore_pass: false,
300+
no_pass_override: false,
302301
check_test_line_numbers_match: false,
303302
normalize_stdout: vec![],
304303
normalize_stderr: vec![],
@@ -332,7 +331,7 @@ impl TestProps {
332331

333332
// copy over select properties to the aux build:
334333
props.incremental_dir = self.incremental_dir.clone();
335-
props.ignore_pass = true;
334+
props.no_pass_override = true;
336335
props.load_from(testfile, revision, config);
337336

338337
props
@@ -618,7 +617,11 @@ impl Config {
618617
}
619618

620619
fn parse_pp_exact(&self, line: &DirectiveLine<'_>) -> Option<Utf8PathBuf> {
621-
if let Some(s) = self.parse_name_value_directive(line, "pp-exact") {
620+
// Unusually, `//@ pp-exact` can be used with or without a colon, so to avoid a panic
621+
// in the parse method we need to make sure there is a colon before calling it.
622+
if line.value_after_colon().is_some()
623+
&& let Some(s) = self.parse_name_value_directive(line, "pp-exact")
624+
{
622625
Some(Utf8PathBuf::from(&s))
623626
} else if self.parse_name_directive(line, "pp-exact") {
624627
line.file_path.file_name().map(Utf8PathBuf::from)
@@ -648,10 +651,17 @@ impl Config {
648651
}
649652

650653
fn parse_name_directive(&self, line: &DirectiveLine<'_>, directive: &str) -> bool {
651-
// FIXME(Zalathar): Ideally, this should raise an error if a name-only
652-
// directive is followed by a colon, since that's the wrong syntax.
653-
// But we would need to fix tests that rely on the current behaviour.
654-
line.name == directive
654+
if line.name != directive {
655+
return false;
656+
}
657+
658+
if line.value_after_colon().is_some() {
659+
let &DirectiveLine { file_path, line_number, .. } = line;
660+
panic!(
661+
"{file_path}:{line_number}: directive `{directive}` must not be followed by a colon"
662+
);
663+
}
664+
true
655665
}
656666

657667
fn parse_name_value_directive(
@@ -665,10 +675,9 @@ impl Config {
665675
return None;
666676
};
667677

668-
// FIXME(Zalathar): This silently discards directives with a matching
669-
// name but no colon. Unfortunately, some directives (e.g. "pp-exact")
670-
// currently rely on _not_ panicking here.
671-
let value = line.value_after_colon()?;
678+
let value = line.value_after_colon().unwrap_or_else(|| {
679+
panic!("{file_path}:{line_number}: directive `{directive}` must be followed by a colon and value");
680+
});
672681
debug!("{}: {}", directive, value);
673682
let value = expand_variables(value.to_owned(), self);
674683

src/tools/compiletest/src/directives/cfg.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const EXTERNAL_IGNORES_LIST: &[&str] = &[
1212
"ignore-gdb-version",
1313
"ignore-llvm-version",
1414
"ignore-parallel-frontend",
15-
"ignore-pass",
1615
// tidy-alphabetical-end
1716
];
1817

src/tools/compiletest/src/directives/directive_names.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
102102
"ignore-nvptx64-nvidia-cuda",
103103
"ignore-openbsd",
104104
"ignore-parallel-frontend",
105-
"ignore-pass",
106105
"ignore-powerpc",
107106
"ignore-powerpc64",
108107
"ignore-remote",
@@ -201,6 +200,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
201200
"needs-wasmtime",
202201
"needs-xray",
203202
"no-auto-check-cfg",
203+
"no-pass-override",
204204
"no-prefer-dynamic",
205205
"normalize-stderr",
206206
"normalize-stderr-32bit",

src/tools/compiletest/src/directives/handlers.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ fn make_directive_handlers_map() -> HashMap<&'static str, Handler> {
199199
multi_handler(PassFailMode::STR_VARIANTS, |config, ln, props| {
200200
props.update_pass_fail_mode(ln, config);
201201
}),
202-
handler(IGNORE_PASS, |config, ln, props| {
203-
config.set_name_directive(ln, IGNORE_PASS, &mut props.ignore_pass);
202+
handler("no-pass-override", |config, ln, props| {
203+
config.set_name_directive(ln, ln.name, &mut props.no_pass_override);
204204
}),
205205
multi_handler(
206206
&[

src/tools/compiletest/src/directives/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,6 @@ fn edition_order() {
11531153
#[test]
11541154
fn test_parse_edition_range() {
11551155
assert_eq!(None, parse_edition_range("hello-world"));
1156-
assert_eq!(None, parse_edition_range("edition"));
11571156

11581157
assert_eq!(Some(EditionRange::Exact(2018.into())), parse_edition_range("edition: 2018"));
11591158
assert_eq!(Some(EditionRange::Exact(2021.into())), parse_edition_range("edition:2021"));

src/tools/compiletest/src/runtest.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,9 @@ impl<'test> TestCx<'test> {
298298
let declared = self.props.pass_fail_mode?;
299299

300300
// Specifying `--pass` only overrides `//@ pass-*` modes, and only if
301-
// the test doesn't opt out with `//@ ignore-pass`.
301+
// the test doesn't opt out with `//@ no-pass-override`.
302302
if let Some(force_pass_mode) = self.config.force_pass_mode
303-
&& !self.props.ignore_pass
303+
&& !self.props.no_pass_override
304304
&& declared.is_pass()
305305
{
306306
match force_pass_mode {

tests/ui/abi/vectorcall-abi-checks.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
//@ add-minicore
22
//@ compile-flags: --crate-type=rlib --target=i586-unknown-linux-gnu -C target-feature=-sse,-sse2
33
//@ build-fail
4-
//@ ignore-pass (test emits codegen-time errors)
54
//@ needs-llvm-components: x86
65
//@ ignore-backends: gcc
76
#![feature(no_core, abi_vectorcall)]

0 commit comments

Comments
 (0)