Skip to content

Commit

Permalink
Rollup merge of #126995 - Oneirical:test-friends-forever, r=Kobzol
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
GuillaumeGomez authored Jun 29, 2024
2 parents 06aeb67 + 53109d5 commit c70a2e3
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 31 deletions.
3 changes: 0 additions & 3 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ run-make/jobserver-error/Makefile
run-make/libs-through-symlinks/Makefile
run-make/libtest-json/Makefile
run-make/libtest-junit/Makefile
run-make/libtest-padding/Makefile
run-make/libtest-thread-limit/Makefile
run-make/link-cfg/Makefile
run-make/link-framework/Makefile
Expand Down Expand Up @@ -125,8 +124,6 @@ run-make/pgo-gen/Makefile
run-make/pgo-indirect-call-promotion/Makefile
run-make/pgo-use/Makefile
run-make/pointer-auth-link-with-c/Makefile
run-make/pretty-print-to-file/Makefile
run-make/pretty-print-with-dep-file/Makefile
run-make/print-calling-conventions/Makefile
run-make/print-target-list/Makefile
run-make/profile/Makefile
Expand Down
14 changes: 0 additions & 14 deletions tests/run-make/libtest-padding/Makefile

This file was deleted.

46 changes: 46 additions & 0 deletions tests/run-make/libtest-padding/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// Benchmarks, when ran as tests, would cause strange indentations
// to appear in the output. This was because padding formatting was
// applied before the conversion from bench to test, and not afterwards.
// Now that this bug has been fixed in #118548, this test checks that it
// does not make a resurgence by comparing the output of --bench with an
// example stdout file.
// See https://github.com/rust-lang/rust/issues/104092

//@ ignore-cross-compile
// Reason: the compiled code is ran
//@ needs-unwind
// Reason: #[bench] requires -Z panic-abort-tests

use run_make_support::{diff, run_with_args, rustc};

fn main() {
rustc().arg("--test").input("tests.rs").run();
let out = run_with_args("tests", &["--test-threads=1"]).stdout_utf8();
diff()
.expected_file("test.stdout")
.actual_text("actual-test-stdout", out)
.normalize(
// Replace all instances of (arbitrary numbers)
// [1.2345 ns/iter (+/- 0.1234)]
// with
// [?? ns/iter (+/- ??)]
r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#,
"?? ns/iter (+/- ??)",
)
// Replace all instances of (arbitrary numbers)
// finished in 8.0000 s
// with
// finished in ??
.normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??")
.run();
let out = run_with_args("tests", &["--test-threads=1", "--bench"]).stdout_utf8();
diff()
.expected_file("bench.stdout")
.actual_text("actual-bench-stdout", out)
.normalize(
r#"(\d+(?:[.,]\d+)*)\s*ns/iter\s*\(\+/-\s*(\d+(?:[.,]\d+)*)\)"#,
"?? ns/iter (+/- ??)",
)
.normalize(r#"finished\s+in\s+(\d+(?:\.\d+)*)"#, "finished in ??")
.run();
}
5 changes: 0 additions & 5 deletions tests/run-make/pretty-print-to-file/Makefile

This file was deleted.

12 changes: 12 additions & 0 deletions tests/run-make/pretty-print-to-file/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// The "pretty-printer" of rustc translates source code into other formats,
// which is useful for debugging. This test checks the "normal" version of
// -Zunpretty, which should format the poorly formatted input.rs into a one-line
// function identical to the one in input.pp.
// See https://github.com/rust-lang/rust/commit/da25539c1ab295ec40261109557dd4526923928c

use run_make_support::{diff, rustc};

fn main() {
rustc().output("input.out").arg("-Zunpretty=normal").input("input.rs").run();
diff().expected_file("input.out").actual_file("input.pp").run();
}
9 changes: 0 additions & 9 deletions tests/run-make/pretty-print-with-dep-file/Makefile

This file was deleted.

17 changes: 17 additions & 0 deletions tests/run-make/pretty-print-with-dep-file/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Passing --emit=dep-info to the Rust compiler should create a .d file...
// but it failed to do so in Rust 1.69.0 when combined with -Z unpretty=expanded
// due to a bug. This test checks that -Z unpretty=expanded does not prevent the
// generation of the dep-info file, and that its -Z unpretty=normal counterpart
// does not get an unexpected dep-info file.
// See https://github.com/rust-lang/rust/issues/112898

use run_make_support::{fs_wrapper, invalid_utf8_contains, rustc};
use std::path::Path;

fn main() {
rustc().emit("dep-info").arg("-Zunpretty=expanded").input("with-dep.rs").run();
invalid_utf8_contains("with-dep.d", "with-dep.rs");
fs_wrapper::remove_file("with-dep.d");
rustc().emit("dep-info").arg("-Zunpretty=normal").input("with-dep.rs").run();
assert!(!Path::new("with-dep.d").exists());
}

0 comments on commit c70a2e3

Please sign in to comment.