Skip to content

Commit 2435cd3

Browse files
committed
rewrite debug-assertions to rmake
1 parent 77bb5cb commit 2435cd3

File tree

4 files changed

+40
-34
lines changed

4 files changed

+40
-34
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ run-make/cross-lang-lto-clang/Makefile
1919
run-make/cross-lang-lto-pgo-smoketest/Makefile
2020
run-make/cross-lang-lto-upstream-rlibs/Makefile
2121
run-make/cross-lang-lto/Makefile
22-
run-make/debug-assertions/Makefile
2322
run-make/dep-info-doesnt-run-much/Makefile
2423
run-make/dep-info-spaces/Makefile
2524
run-make/dep-info/Makefile

tests/run-make/debug-assertions/Makefile

-27
This file was deleted.

tests/run-make/debug-assertions/debug.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
#![feature(rustc_attrs)]
22
#![deny(warnings)]
33

4-
use std::env;
54
use std::thread;
65

76
fn main() {
8-
let should_fail = env::args().nth(1) == Some("bad".to_string());
9-
10-
assert_eq!(thread::spawn(debug_assert_eq).join().is_err(), should_fail);
11-
assert_eq!(thread::spawn(debug_assert).join().is_err(), should_fail);
12-
assert_eq!(thread::spawn(overflow).join().is_err(), should_fail);
7+
assert!(thread::spawn(debug_assert_eq).join().is_ok());
8+
assert!(thread::spawn(debug_assert).join().is_ok());
9+
assert!(thread::spawn(overflow).join().is_ok());
1310
}
1411

1512
fn debug_assert_eq() {
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// debug.rs contains some "debug assertion" statements which
2+
// should only be enabled in either non-optimized builds or when
3+
// `-C debug-assertions` is set to yes. These debug assertions
4+
// are guaranteed to fail, so this test checks that the run command
5+
// fails where debug assertions should be activated, and succeeds where
6+
// debug assertions should be disabled.
7+
// See https://github.com/rust-lang/rust/pull/22980
8+
9+
//@ ignore-cross-compile
10+
//@ needs-unwind
11+
12+
use run_make_support::{run, run_fail, rustc};
13+
14+
fn main() {
15+
rustc().input("debug.rs").arg("-Cdebug-assertions=no").run();
16+
run("debug");
17+
rustc().input("debug.rs").opt_level("0").run();
18+
run_fail("debug");
19+
rustc().input("debug.rs").opt_level("1").run();
20+
run("debug");
21+
rustc().input("debug.rs").opt_level("2").run();
22+
run("debug");
23+
rustc().input("debug.rs").opt_level("3").run();
24+
run("debug");
25+
rustc().input("debug.rs").opt_level("s").run();
26+
run("debug");
27+
rustc().input("debug.rs").opt_level("z").run();
28+
run("debug");
29+
rustc().input("debug.rs").opt().run();
30+
run("debug");
31+
rustc().input("debug.rs").run();
32+
run_fail("debug");
33+
rustc().input("debug.rs").opt().arg("-Cdebug-assertions=yes").run();
34+
run_fail("debug");
35+
rustc().input("debug.rs").opt_level("1").arg("-Cdebug-assertions=yes").run();
36+
run_fail("debug");
37+
}

0 commit comments

Comments
 (0)