Skip to content

Commit

Permalink
rewrite debug-assertions to rmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Oneirical committed Jun 21, 2024
1 parent 77bb5cb commit 2435cd3
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 34 deletions.
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,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
Expand Down
27 changes: 0 additions & 27 deletions tests/run-make/debug-assertions/Makefile

This file was deleted.

9 changes: 3 additions & 6 deletions tests/run-make/debug-assertions/debug.rs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
37 changes: 37 additions & 0 deletions tests/run-make/debug-assertions/rmake.rs
Original file line number Diff line number Diff line change
@@ -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");
}

0 comments on commit 2435cd3

Please sign in to comment.