Skip to content

Commit d28c5ba

Browse files
committed
Provide way for ui tests to opt out of having their output checked.
Namely, this adds support for: * `// dont-check-compiler-stdout`, and * `// dont-check-compiler-stderr`. Obviously almost all ui tests wont want to opt into these, since the whole point of a ui test is to check the compiler ui. However, since this PR is converting run-pass into (another set of) ui tests, these header options make sense in that context. (Also this puts us into a better position for eventually turning *every* test suite into a ui test suite, by making ui-ness the default and forcing tests to opt out explicitly.)
1 parent ae0a53a commit d28c5ba

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/tools/compiletest/src/header.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ pub struct TestProps {
199199
pub force_host: bool,
200200
// Check stdout for error-pattern output as well as stderr
201201
pub check_stdout: bool,
202+
// For UI tests, allows compiler to generate arbitrary output to stdout
203+
pub dont_check_compiler_stdout: bool,
204+
// For UI tests, allows compiler to generate arbitrary output to stderr
205+
pub dont_check_compiler_stderr: bool,
202206
// Don't force a --crate-type=dylib flag on the command line
203207
pub no_prefer_dynamic: bool,
204208
// Run --pretty expanded when running pretty printing tests
@@ -249,6 +253,8 @@ impl TestProps {
249253
build_aux_docs: false,
250254
force_host: false,
251255
check_stdout: false,
256+
dont_check_compiler_stdout: false,
257+
dont_check_compiler_stderr: false,
252258
no_prefer_dynamic: false,
253259
pretty_expanded: false,
254260
pretty_mode: "normal".to_string(),
@@ -327,6 +333,14 @@ impl TestProps {
327333
self.check_stdout = config.parse_check_stdout(ln);
328334
}
329335

336+
if !self.dont_check_compiler_stdout {
337+
self.dont_check_compiler_stdout = config.parse_dont_check_compiler_stdout(ln);
338+
}
339+
340+
if !self.dont_check_compiler_stderr {
341+
self.dont_check_compiler_stderr = config.parse_dont_check_compiler_stderr(ln);
342+
}
343+
330344
if !self.no_prefer_dynamic {
331345
self.no_prefer_dynamic = config.parse_no_prefer_dynamic(ln);
332346
}
@@ -510,6 +524,14 @@ impl Config {
510524
self.parse_name_directive(line, "check-stdout")
511525
}
512526

527+
fn parse_dont_check_compiler_stdout(&self, line: &str) -> bool {
528+
self.parse_name_directive(line, "dont-check-compiler-stdout")
529+
}
530+
531+
fn parse_dont_check_compiler_stderr(&self, line: &str) -> bool {
532+
self.parse_name_directive(line, "dont-check-compiler-stderr")
533+
}
534+
513535
fn parse_no_prefer_dynamic(&self, line: &str) -> bool {
514536
self.parse_name_directive(line, "no-prefer-dynamic")
515537
}

src/tools/compiletest/src/runtest.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2654,8 +2654,12 @@ impl<'test> TestCx<'test> {
26542654
let normalized_stderr = self.normalize_output(&stderr, &self.props.normalize_stderr);
26552655

26562656
let mut errors = 0;
2657-
errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
2658-
errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr);
2657+
if !self.props.dont_check_compiler_stdout {
2658+
errors += self.compare_output("stdout", &normalized_stdout, &expected_stdout);
2659+
}
2660+
if !self.props.dont_check_compiler_stderr {
2661+
errors += self.compare_output("stderr", &normalized_stderr, &expected_stderr);
2662+
}
26592663

26602664
let modes_to_prune = vec![CompareMode::Nll];
26612665
self.prune_duplicate_outputs(&modes_to_prune);

0 commit comments

Comments
 (0)