Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c70a2e3

Browse files
authoredJun 29, 2024
Rollup merge of #126995 - Oneirical:test-friends-forever, r=Kobzol
Migrate `pretty-print-with-dep-file`, `pretty-print-to-file` and `libtest-padding` `run-make` tests to rmake Part of #121876 and the associated [Google Summer of Code project](https://blog.rust-lang.org/2024/05/01/gsoc-2024-selected-projects.html).
2 parents 06aeb67 + 53109d5 commit c70a2e3

File tree

7 files changed

+75
-31
lines changed

7 files changed

+75
-31
lines changed
 

‎src/tools/tidy/src/allowed_run_make_makefiles.txt

-3
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,6 @@ run-make/jobserver-error/Makefile
8282
run-make/libs-through-symlinks/Makefile
8383
run-make/libtest-json/Makefile
8484
run-make/libtest-junit/Makefile
85-
run-make/libtest-padding/Makefile
8685
run-make/libtest-thread-limit/Makefile
8786
run-make/link-cfg/Makefile
8887
run-make/link-framework/Makefile
@@ -125,8 +124,6 @@ run-make/pgo-gen/Makefile
125124
run-make/pgo-indirect-call-promotion/Makefile
126125
run-make/pgo-use/Makefile
127126
run-make/pointer-auth-link-with-c/Makefile
128-
run-make/pretty-print-to-file/Makefile
129-
run-make/pretty-print-with-dep-file/Makefile
130127
run-make/print-calling-conventions/Makefile
131128
run-make/print-target-list/Makefile
132129
run-make/profile/Makefile

‎tests/run-make/libtest-padding/Makefile

-14
This file was deleted.
+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// Benchmarks, when ran as tests, would cause strange indentations
2+
// to appear in the output. This was because padding formatting was
3+
// applied before the conversion from bench to test, and not afterwards.
4+
// Now that this bug has been fixed in #118548, this test checks that it
5+
// does not make a resurgence by comparing the output of --bench with an
6+
// example stdout file.
7+
// See https://github.com/rust-lang/rust/issues/104092
8+
9+
//@ ignore-cross-compile
10+
// Reason: the compiled code is ran
11+
//@ needs-unwind
12+
// Reason: #[bench] requires -Z panic-abort-tests
13+
14+
use run_make_support::{diff, run_with_args, rustc};
15+
16+
fn main() {
17+
rustc().arg("--test").input("tests.rs").run();
18+
let out = run_with_args("tests", &["--test-threads=1"]).stdout_utf8();
19+
diff()
20+
.expected_file("test.stdout")
21+
.actual_text("actual-test-stdout", out)
22+
.normalize(
23+
// Replace all instances of (arbitrary numbers)
24+
// [1.2345 ns/iter (+/- 0.1234)]
25+
// with
26+
// [?? ns/iter (+/- ??)]
27+
r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#,
28+
"?? ns/iter (+/- ??)",
29+
)
30+
// Replace all instances of (arbitrary numbers)
31+
// finished in 8.0000 s
32+
// with
33+
// finished in ??
34+
.normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??")
35+
.run();
36+
let out = run_with_args("tests", &["--test-threads=1", "--bench"]).stdout_utf8();
37+
diff()
38+
.expected_file("bench.stdout")
39+
.actual_text("actual-bench-stdout", out)
40+
.normalize(
41+
r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#,
42+
"?? ns/iter (+/- ??)",
43+
)
44+
.normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??")
45+
.run();
46+
}

‎tests/run-make/pretty-print-to-file/Makefile

-5
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// The "pretty-printer" of rustc translates source code into other formats,
2+
// which is useful for debugging. This test checks the "normal" version of
3+
// -Zunpretty, which should format the poorly formatted input.rs into a one-line
4+
// function identical to the one in input.pp.
5+
// See https://github.com/rust-lang/rust/commit/da25539c1ab295ec40261109557dd4526923928c
6+
7+
use run_make_support::{diff, rustc};
8+
9+
fn main() {
10+
rustc().output("input.out").arg("-Zunpretty=normal").input("input.rs").run();
11+
diff().expected_file("input.out").actual_file("input.pp").run();
12+
}

‎tests/run-make/pretty-print-with-dep-file/Makefile

-9
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Passing --emit=dep-info to the Rust compiler should create a .d file...
2+
// but it failed to do so in Rust 1.69.0 when combined with -Z unpretty=expanded
3+
// due to a bug. This test checks that -Z unpretty=expanded does not prevent the
4+
// generation of the dep-info file, and that its -Z unpretty=normal counterpart
5+
// does not get an unexpected dep-info file.
6+
// See https://github.com/rust-lang/rust/issues/112898
7+
8+
use run_make_support::{fs_wrapper, invalid_utf8_contains, rustc};
9+
use std::path::Path;
10+
11+
fn main() {
12+
rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run();
13+
invalid_utf8_contains("with-dep.d", "with-dep.rs");
14+
fs_wrapper::remove_file("with-dep.d");
15+
rustc().emit("dep-info").arg("-Zunpretty=normal").input("with-dep.rs").run();
16+
assert!(!Path::new("with-dep.d").exists());
17+
}

0 commit comments

Comments
 (0)
Failed to load comments.