Skip to content

Commit 8ca5497

Browse files
committed
use parallel front end(-Zthreads=2) in ui tests
1 parent 9859bf2 commit 8ca5497

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

src/tools/compiletest/src/command-list.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
227227
"rustfix-only-machine-applicable",
228228
"should-fail",
229229
"should-ice",
230+
"single-thread",
230231
"stderr-per-bitwidth",
231232
"test-mir-pass",
232233
"unique-doc-out-dir",

src/tools/compiletest/src/header.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,8 @@ pub struct TestProps {
137137
pub dont_check_compiler_stdout: bool,
138138
// For UI tests, allows compiler to generate arbitrary output to stderr
139139
pub dont_check_compiler_stderr: bool,
140+
// Use single thread for the rustc front end.
141+
pub single_thread: bool,
140142
// When checking the output of stdout or stderr check
141143
// that the lines of expected output are a subset of the actual output.
142144
pub compare_output_lines_by_subset: bool,
@@ -259,6 +261,7 @@ mod directives {
259261
pub const KNOWN_BUG: &'static str = "known-bug";
260262
pub const TEST_MIR_PASS: &'static str = "test-mir-pass";
261263
pub const REMAP_SRC_BASE: &'static str = "remap-src-base";
264+
pub const SINGLE_THREAD: &'static str = "single-thread";
262265
pub const COMPARE_OUTPUT_LINES_BY_SUBSET: &'static str = "compare-output-lines-by-subset";
263266
pub const LLVM_COV_FLAGS: &'static str = "llvm-cov-flags";
264267
pub const FILECHECK_FLAGS: &'static str = "filecheck-flags";
@@ -291,6 +294,7 @@ impl TestProps {
291294
build_aux_docs: false,
292295
unique_doc_out_dir: false,
293296
force_host: false,
297+
single_thread: false,
294298
check_stdout: false,
295299
check_run_results: false,
296300
dont_check_compiler_stdout: false,
@@ -582,6 +586,7 @@ impl TestProps {
582586
|s| s.trim().to_string(),
583587
);
584588
config.set_name_directive(ln, REMAP_SRC_BASE, &mut self.remap_src_base);
589+
config.set_name_directive(ln, SINGLE_THREAD, &mut self.single_thread);
585590
config.set_name_directive(
586591
ln,
587592
COMPARE_OUTPUT_LINES_BY_SUBSET,

src/tools/compiletest/src/runtest.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2058,8 +2058,12 @@ impl<'test> TestCx<'test> {
20582058
};
20592059
rustc.arg(input_file);
20602060

2061-
// Use a single thread for efficiency and a deterministic error message order
2062-
rustc.arg("-Zthreads=1");
2061+
// Use parallel front end or not
2062+
if self.props.single_thread {
2063+
rustc.arg("-Zthreads=1");
2064+
} else {
2065+
rustc.arg("-Zthreads=2");
2066+
}
20632067

20642068
// Hide libstd sources from ui tests to make sure we generate the stderr
20652069
// output that users will see.
@@ -4524,8 +4528,9 @@ impl<'test> TestCx<'test> {
45244528
// provide extra output on failure, for example a WebAssembly runtime
45254529
// might print the stack trace of an `unreachable` instruction by
45264530
// default.
4527-
let compare_output_by_lines =
4528-
self.props.compare_output_lines_by_subset || self.config.runner.is_some();
4531+
let compare_output_by_lines = !self.props.single_thread
4532+
|| self.props.compare_output_lines_by_subset
4533+
|| self.config.runner.is_some();
45294534

45304535
let tmp;
45314536
let (expected, actual): (&str, &str) = if compare_output_by_lines {

tests/ui/fuel/optimization-fuel-0.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::mem::size_of;
66

77
//@ compile-flags: -Z fuel=foo=0
8-
8+
//@ single-thread
99
#[allow(dead_code)]
1010
struct S1(u8, u16, u8);
1111
#[allow(dead_code)]

tests/ui/fuel/optimization-fuel-1.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use std::mem::size_of;
66

77
//@ compile-flags: -Z fuel=foo=1
8-
8+
//@ single-thread
99
#[allow(dead_code)]
1010
struct S1(u8, u16, u8);
1111
#[allow(dead_code)]

tests/ui/fuel/print-fuel.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// (#55495: The --error-format is to sidestep an issue in our test harness)
55
//@ compile-flags: -C opt-level=0 --error-format human -Z print-fuel=foo
6+
//@ single-thread
67
//@ check-pass
78

89
struct S1(u8, u16, u8);

tests/ui/lint/issue-79546-fuel-ice.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// Regression test for the ICE described in #79546.
22

33
//@ compile-flags: --cap-lints=allow -Zfuel=issue79546=0
4+
//@ single-thread
45
//@ check-pass
56
#![crate_name="issue79546"]
67

0 commit comments

Comments
 (0)