Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x.py ignores config.toml's debug-assertions-std for unit tests #79481

Closed
ssomers opened this issue Nov 27, 2020 · 4 comments
Closed

x.py ignores config.toml's debug-assertions-std for unit tests #79481

ssomers opened this issue Nov 27, 2020 · 4 comments
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@ssomers
Copy link
Contributor

ssomers commented Nov 27, 2020

If you have in your config.toml file (or whichever file --config says), only this change to config.toml.example:

debug-assertions-std = true

debug assertions in src/liballoc or library/alloc used to be armed. Since #73374, debug assertions only go off if you also turn on debug. EDIT: since some point, even that doesn't help.

@ssomers ssomers added the C-bug Category: This is a bug. label Nov 27, 2020
@jyn514 jyn514 added T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Nov 28, 2020
@jyn514
Copy link
Member

jyn514 commented Oct 11, 2021

@ssomers I can't reproduce. I added this assert:

diff --git a/library/core/tests/iter/traits/iterator.rs b/library/core/tests/iter/traits/iterator.rs
index 422e389e380..77e1effc764 100644
--- a/library/core/tests/iter/traits/iterator.rs
+++ b/library/core/tests/iter/traits/iterator.rs
@@ -26,6 +26,7 @@ fn cmp(&self, other: &Self) -> core::cmp::Ordering {
 
 #[test]
 fn test_lt() {
+    debug_assert!(false);
     let empty: [isize; 0] = [];
     let xs = [1, 2, 3];
     let ys = [1, 2, 0];

and set debug = false and debug-assertions-std = true, and got an assertion failure as expected.

Are you expecting assertions to run in coretests maybe?

@ssomers
Copy link
Contributor Author

ssomers commented Oct 11, 2021

Not exactly sure what I was doing back then, nor what you mean with running in coretests. Today, I'd expect, for instance when
adding to library/alloc/src/collections/btree/node/tests.rs:

#[test]
fn test_assert() {
    assert!(false)
}

#[test]
fn test_debug_assert() {
    debug_assert!(false)
}

and running python x.py test library/alloc --no-doc, that both new test cases fail. What I'm seeing is that the debug_assert doesn't even fail when enabling debug, debug-assertions and debug-assertions-std in config.toml.

@jyn514 jyn514 changed the title x.py ignores config.toml's debug-assertions-std x.py ignores config.toml's debug-assertions-std for unit tests Nov 25, 2021
@jyn514
Copy link
Member

jyn514 commented Nov 26, 2021

@ssomers I'm still not able to replicate this. I ran x test library/alloc --stage 0 --test-args debug_assert with your test case added and the test failed appropriately:

Testing alloc stage0 (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
   Compiling getrandom v0.1.14
   Compiling ppv-lite86 v0.2.8
   Compiling rand_core v0.5.1
   Compiling rand_chacha v0.2.2
   Compiling rand_xorshift v0.2.0
   Compiling rand v0.7.3
   Compiling alloc v0.0.0 (/home/joshua/src/rust/rust/library/alloc)
    Finished release [optimized + debuginfo] target(s) in 1m 15s
     Running unittests (build/x86_64-unknown-linux-gnu/stage0-std/x86_64-unknown-linux-gnu/release/deps/alloc-cd5eecf891e8cfac)

running 1 test
F
failures:

---- collections::btree::node::tests::test_debug_assert stdout ----
thread 'collections::btree::node::tests::test_debug_assert' panicked at 'assertion failed: false', library/alloc/src/collections/btree/node/tests.rs:106:5

@ssomers
Copy link
Contributor Author

ssomers commented Nov 27, 2021

Well, I can still replicate it… on the master at the time. I located the fix at auto merge #90042 (25 October).

And it's really flawless now. The debug assertions detonate if debug or debug-assertions-std is true, or both, and you don't need to clean anything before building to see it.

@ssomers ssomers closed this as completed Nov 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

2 participants