diff options
| author | ywxt <ywxtcwh@gmail.com> | 2025-08-15 14:16:32 +0800 |
|---|---|---|
| committer | ywxt <ywxtcwh@gmail.com> | 2025-08-15 14:16:32 +0800 |
| commit | e17989edc7dfcf923626964cb8d59a570f32c8bf (patch) | |
| tree | 16451de3c07c85244ea31c03bce100fdf8984018 /src/tools | |
| parent | 898aff704d6f0d00343f21d31b8b9bfac8e43007 (diff) | |
| download | rust-e17989edc7dfcf923626964cb8d59a570f32c8bf.tar.gz rust-e17989edc7dfcf923626964cb8d59a570f32c8bf.zip | |
Add the directive `compare-output-by-lines`
Diffstat (limited to 'src/tools')
| -rw-r--r-- | src/tools/compiletest/src/directives.rs | 9 | ||||
| -rw-r--r-- | src/tools/compiletest/src/directives/directive_names.rs | 1 | ||||
| -rw-r--r-- | src/tools/compiletest/src/runtest.rs | 6 |
3 files changed, 15 insertions, 1 deletions
diff --git a/src/tools/compiletest/src/directives.rs b/src/tools/compiletest/src/directives.rs index 13e694b7f03..027ee063a49 100644 --- a/src/tools/compiletest/src/directives.rs +++ b/src/tools/compiletest/src/directives.rs @@ -205,6 +205,8 @@ pub struct TestProps { pub dont_require_annotations: HashSet<ErrorKind>, /// Whether pretty printers should be disabled in gdb. pub disable_gdb_pretty_printers: bool, + /// Compare the output by lines, rather than as a single string. + pub compare_output_by_lines: bool, } mod directives { @@ -254,6 +256,7 @@ mod directives { // This isn't a real directive, just one that is probably mistyped often pub const INCORRECT_COMPILER_FLAGS: &'static str = "compiler-flags"; pub const DISABLE_GDB_PRETTY_PRINTERS: &'static str = "disable-gdb-pretty-printers"; + pub const COMPARE_OUTPUT_BY_LINES: &'static str = "compare-output-by-lines"; } impl TestProps { @@ -310,6 +313,7 @@ impl TestProps { add_core_stubs: false, dont_require_annotations: Default::default(), disable_gdb_pretty_printers: false, + compare_output_by_lines: false, } } @@ -664,6 +668,11 @@ impl TestProps { DISABLE_GDB_PRETTY_PRINTERS, &mut self.disable_gdb_pretty_printers, ); + config.set_name_directive( + ln, + COMPARE_OUTPUT_BY_LINES, + &mut self.compare_output_by_lines, + ); }, ); diff --git a/src/tools/compiletest/src/directives/directive_names.rs b/src/tools/compiletest/src/directives/directive_names.rs index f7955429d83..9bdd8e9fa11 100644 --- a/src/tools/compiletest/src/directives/directive_names.rs +++ b/src/tools/compiletest/src/directives/directive_names.rs @@ -17,6 +17,7 @@ pub(crate) const KNOWN_DIRECTIVE_NAMES: &[&str] = &[ "check-run-results", "check-stdout", "check-test-line-numbers-match", + "compare-output-by-lines", "compile-flags", "disable-gdb-pretty-printers", "doc-flags", diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index be4663fffbe..af35302b55b 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -2749,7 +2749,11 @@ impl<'test> TestCx<'test> { // Wrapper tools set by `runner` might provide extra output on failure, // for example a WebAssembly runtime might print the stack trace of an // `unreachable` instruction by default. - let compare_output_by_lines = self.config.runner.is_some(); + // + // Also, some tests like `ui/parallel-rustc` have non-deterministic + // orders of output, so we need to compare by lines. + let compare_output_by_lines = + self.props.compare_output_by_lines || self.config.runner.is_some(); let tmp; let (expected, actual): (&str, &str) = if compare_output_by_lines { |
