From cb1281b76d4d90fd66bd76507e583c69625e037d Mon Sep 17 00:00:00 2001 From: Oneirical Date: Fri, 21 Jun 2024 13:35:47 -0400 Subject: [PATCH] rewrite debug-assertions to rmake --- .../tidy/src/allowed_run_make_makefiles.txt | 1 - tests/run-make/debug-assertions/Makefile | 27 -------------- tests/run-make/debug-assertions/debug.rs | 9 ++--- tests/run-make/debug-assertions/rmake.rs | 37 +++++++++++++++++++ 4 files changed, 40 insertions(+), 34 deletions(-) delete mode 100644 tests/run-make/debug-assertions/Makefile create mode 100644 tests/run-make/debug-assertions/rmake.rs diff --git a/src/tools/tidy/src/allowed_run_make_makefiles.txt b/src/tools/tidy/src/allowed_run_make_makefiles.txt index 2bc3acc58cb..6199dce7d98 100644 --- a/src/tools/tidy/src/allowed_run_make_makefiles.txt +++ b/src/tools/tidy/src/allowed_run_make_makefiles.txt @@ -18,7 +18,6 @@ run-make/cross-lang-lto-clang/Makefile run-make/cross-lang-lto-pgo-smoketest/Makefile run-make/cross-lang-lto-upstream-rlibs/Makefile run-make/cross-lang-lto/Makefile -run-make/debug-assertions/Makefile run-make/dep-info-doesnt-run-much/Makefile run-make/dep-info-spaces/Makefile run-make/dep-info/Makefile diff --git a/tests/run-make/debug-assertions/Makefile b/tests/run-make/debug-assertions/Makefile deleted file mode 100644 index 4501459e9d1..00000000000 --- a/tests/run-make/debug-assertions/Makefile +++ /dev/null @@ -1,27 +0,0 @@ -# ignore-cross-compile -# needs-unwind -include ../tools.mk - -all: - $(RUSTC) debug.rs -C debug-assertions=no - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=0 - $(call RUN,debug) bad - $(RUSTC) debug.rs -C opt-level=1 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=2 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=3 - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=s - $(call RUN,debug) good - $(RUSTC) debug.rs -C opt-level=z - $(call RUN,debug) good - $(RUSTC) debug.rs -O - $(call RUN,debug) good - $(RUSTC) debug.rs - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -O - $(call RUN,debug) bad - $(RUSTC) debug.rs -C debug-assertions=yes -C opt-level=1 - $(call RUN,debug) bad diff --git a/tests/run-make/debug-assertions/debug.rs b/tests/run-make/debug-assertions/debug.rs index 9eebf60ded0..c6e4bddc34c 100644 --- a/tests/run-make/debug-assertions/debug.rs +++ b/tests/run-make/debug-assertions/debug.rs @@ -1,15 +1,12 @@ #![feature(rustc_attrs)] #![deny(warnings)] -use std::env; use std::thread; fn main() { - let should_fail = env::args().nth(1) == Some("bad".to_string()); - - assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail); - assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail); - assert_eq!(thread::spawn(overflow).join().is_err(), should_fail); + assert!(thread::spawn(debug_assert_eq).join().is_ok()); + assert!(thread::spawn(debug_assert).join().is_ok()); + assert!(thread::spawn(overflow).join().is_ok()); } fn debug_assert_eq() { diff --git a/tests/run-make/debug-assertions/rmake.rs b/tests/run-make/debug-assertions/rmake.rs new file mode 100644 index 00000000000..ba8be9488a8 --- /dev/null +++ b/tests/run-make/debug-assertions/rmake.rs @@ -0,0 +1,37 @@ +// debug.rs contains some "debug assertion" statements which +// should only be enabled in either non-optimized builds or when +// `-C debug-assertions` is set to yes. These debug assertions +// are guaranteed to fail, so this test checks that the run command +// fails where debug assertions should be activated, and succeeds where +// debug assertions should be disabled. +// See https://github.com/rust-lang/rust/pull/22980 + +//@ ignore-cross-compile +//@ needs-unwind + +use run_make_support::{run, run_fail, rustc}; + +fn main() { + rustc().input("debug.rs").arg("-Cdebug-assertions=no").run(); + run("debug"); + rustc().input("debug.rs").opt_level("0").run(); + run_fail("debug"); + rustc().input("debug.rs").opt_level("1").run(); + run("debug"); + rustc().input("debug.rs").opt_level("2").run(); + run("debug"); + rustc().input("debug.rs").opt_level("3").run(); + run("debug"); + rustc().input("debug.rs").opt_level("s").run(); + run("debug"); + rustc().input("debug.rs").opt_level("z").run(); + run("debug"); + rustc().input("debug.rs").opt().run(); + run("debug"); + rustc().input("debug.rs").run(); + run_fail("debug"); + rustc().input("debug.rs").opt().arg("-Cdebug-assertions=yes").run(); + run_fail("debug"); + rustc().input("debug.rs").opt_level("1").arg("-Cdebug-assertions=yes").run(); + run_fail("debug"); +}