Skip to content

Commit bdc19a9

Browse files
committed
Auto merge of #145384 - ywxt:parallel-tests, r=jieyouxu
Add more tests for the parallel rustc At the moment, the parallel frontend test cases are severely lacking. Althought some reported issues have been resolved, they haven't been added into the tests. This PR arranges the resolved ICE issues and adds tests for them. Whether it is worthwhile to add a separate test suite for the paralel frontend still requires futher discussion. But we are trying coveraging issues being resolved through capability of the existing UI test suite. Discussion: [Zulip](https://rust-lang.zulipchat.com/#narrow/channel/233931-t-compiler.2Fmajor-changes/topic/Proposal.20for.20a.20dedicated.20test.20suite.20for.20t.E2.80.A6.20compiler-team.23906) Related issues: - #120760 - #124423 fixed by #140358 - #127971 fxied by #140358 - #120601 fixed by #127311 cc `@jieyouxu`
2 parents 8e3710e + 36ab1bf commit bdc19a9

22 files changed

+722
-19
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ for more details.
111111
| `forbid-output` | A pattern which must not appear in stderr/`cfail` output | `ui`, `incremental` | Regex pattern |
112112
| `run-flags` | Flags passed to the test executable | `ui` | Arbitrary flags |
113113
| `known-bug` | No error annotation needed due to known bug | `ui`, `crashes`, `incremental` | Issue number `#123456` |
114+
| `compare-output-by-lines` | Compare the output by lines, rather than as a single string | All | N/A |
114115

115116
[^check_stdout]: presently <!-- date-check: Oct 2024 --> this has a weird quirk
116117
where the test binary's stdout and stderr gets concatenated and then

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ will check for output files:
9595
[Normalization](#normalization)).
9696
- `dont-check-compiler-stderr` — Ignores stderr from the compiler.
9797
- `dont-check-compiler-stdout` — Ignores stdout from the compiler.
98+
- `compare-output-by-lines` — Some tests have non-deterministic orders of output, so we need to compare by lines.
9899

99100
UI tests run with `-Zdeduplicate-diagnostics=no` flag which disables rustc's
100101
built-in diagnostic deduplication mechanism. This means you may see some

src/tools/compiletest/src/directives.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,8 @@ pub struct TestProps {
205205
pub dont_require_annotations: HashSet<ErrorKind>,
206206
/// Whether pretty printers should be disabled in gdb.
207207
pub disable_gdb_pretty_printers: bool,
208+
/// Compare the output by lines, rather than as a single string.
209+
pub compare_output_by_lines: bool,
208210
}
209211

210212
mod directives {
@@ -254,6 +256,7 @@ mod directives {
254256
// This isn't a real directive, just one that is probably mistyped often
255257
pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags";
256258
pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers";
259+
pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines";
257260
}
258261

259262
impl TestProps {
@@ -310,6 +313,7 @@ impl TestProps {
310313
add_core_stubs: false,
311314
dont_require_annotations: Default::default(),
312315
disable_gdb_pretty_printers: false,
316+
compare_output_by_lines: false,
313317
}
314318
}
315319

@@ -664,6 +668,11 @@ impl TestProps {
664668
DISABLE_GDB_PRETTY_PRINTERS,
665669
&mut self.disable_gdb_pretty_printers,
666670
);
671+
config.set_name_directive(
672+
ln,
673+
COMPARE_OUTPUT_BY_LINES,
674+
&mut self.compare_output_by_lines,
675+
);
667676
},
668677
);
669678

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
1717
"check-run-results",
1818
"check-stdout",
1919
"check-test-line-numbers-match",
20+
"compare-output-by-lines",
2021
"compile-flags",
2122
"disable-gdb-pretty-printers",
2223
"doc-flags",

src/tools/compiletest/src/runtest.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2754,7 +2754,11 @@ impl<'test> TestCx<'test> {
27542754
// Wrapper tools set by `runner` might provide extra output on failure,
27552755
// for example a WebAssembly runtime might print the stack trace of an
27562756
// `unreachable` instruction by default.
2757-
let compare_output_by_lines = self.config.runner.is_some();
2757+
//
2758+
// Also, some tests like `ui/parallel-rustc` have non-deterministic
2759+
// orders of output, so we need to compare by lines.
2760+
let compare_output_by_lines =
2761+
self.props.compare_output_by_lines || self.config.runner.is_some();
27582762

27592763
let tmp;
27602764
let (expected, actual): (&str, &str) = if compare_output_by_lines {
Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
1+
// Test for #111528, the ice issue cause waiting on a query that panicked
2+
//
13
//@ compile-flags: -Z threads=16
24
//@ build-fail
5+
//@ compare-output-by-lines
36

4-
#![crate_type="rlib"]
7+
#![crate_type = "rlib"]
58
#![allow(warnings)]
69

7-
#[export_name="fail"]
8-
pub fn a() {
9-
}
10+
#[export_name = "fail"]
11+
pub fn a() {}
1012

11-
#[export_name="fail"]
13+
#[export_name = "fail"]
1214
pub fn b() {
13-
//~^ ERROR symbol `fail` is already defined
15+
//~^ ERROR symbol `fail` is already defined
1416
}
1517

1618
fn main() {}

tests/ui/parallel-rustc/cache-after-waiting-issue-111528.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: symbol `fail` is already defined
2-
--> $DIR/cache-after-waiting-issue-111528.rs:12:1
2+
--> $DIR/cache-after-waiting-issue-111528.rs:14:1
33
|
44
LL | pub fn b() {
55
| ^^^^^^^^^^
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// Test for #135870, which causes a deadlock bug
2+
//
3+
//@ compile-flags: -Z threads=2
4+
//@ compare-output-by-lines
5+
6+
const FOO: usize = FOO; //~ ERROR cycle detected when simplifying constant for the type system `FOO`
7+
8+
fn main() {}

tests/ui/parallel-rustc/cycle_crash.stderr renamed to tests/ui/parallel-rustc/cycle_crash-issue-135870.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
error[E0391]: cycle detected when simplifying constant for the type system `FOO`
2-
--> $DIR/cycle_crash.rs:3:1
2+
--> $DIR/cycle_crash-issue-135870.rs:6:1
33
|
44
LL | const FOO: usize = FOO;
55
| ^^^^^^^^^^^^^^^^
66
|
77
note: ...which requires const-evaluating + checking `FOO`...
8-
--> $DIR/cycle_crash.rs:3:20
8+
--> $DIR/cycle_crash-issue-135870.rs:6:20
99
|
1010
LL | const FOO: usize = FOO;
1111
| ^^^

tests/ui/parallel-rustc/cycle_crash.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

0 commit comments

Comments
 (0)