From 07576d3ed07d558a72cdc7e85c88e3fab12a1986 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 18 Apr 2018 20:59:51 -0700 Subject: [PATCH] Make test-all.sh run unit tests in debug mode. It turns out that "cargo test --release" doesn't use `[profile.release]`; it uses `[profile.bench]` instead; see [here](https://doc.rust-lang.org/cargo/reference/manifest.html) for details. So the plan to run the tests in optimized mode but with debug-assertions enabled didn't actually work, and we had an actual failing unit test that was hidden because assertions were disabled. So, this makes test-all.sh just run the unit tests in debug mode, as is the norm for Rust packages, and fixes the buggy test. This also removes the `[profile.release]` override from the top-level Cargo.toml file too. We don't need it now that we're not running tests in release mode, and it had confused multiple people because it made Cretonne's in-tree builds different from how Cretonne is built when used as a dependency in other projects. --- cranelift/Cargo.toml | 8 -------- cranelift/test-all.sh | 12 +++++++----- lib/module/src/data_context.rs | 4 ++-- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/cranelift/Cargo.toml b/cranelift/Cargo.toml index 4961a6fef6..543bbcf8a0 100644 --- a/cranelift/Cargo.toml +++ b/cranelift/Cargo.toml @@ -31,11 +31,3 @@ tempdir = "0.3.5" term = "0.5.1" [workspace] - -# Enable debug assertions and parallel compilation when building cretonne-tools -# since they are for testing and development mostly. This doesn't affect the -# flags used to build the cretonne-* crates when used as a dependency. -[profile.release] -opt-level = 2 -debug-assertions = true -codegen-units = 4 diff --git a/cranelift/test-all.sh b/cranelift/test-all.sh index ba3faf70b0..82ec347dac 100755 --- a/cranelift/test-all.sh +++ b/cranelift/test-all.sh @@ -41,15 +41,17 @@ if [ -n "$needcheck" ]; then touch $tsfile || echo no target directory fi +# Make sure the code builds in release mode. +banner "Rust release build" +cargo build --release + # Make sure the code builds in debug mode. banner "Rust debug build" cargo build -# Make sure the code builds in release mode, and run the unit tests. We run -# these in release mode for speed, but note that the top-level Cargo.toml file -# does enable debug assertions in release builds. -banner "Rust release build and unit tests" -cargo test --all --release +# Run the tests. We run these in debug mode so that assertions are enabled. +banner "Rust unit tests" +cargo test --all # Make sure the documentation builds. banner "Rust documentation: $topdir/target/doc/cretonne/index.html" diff --git a/lib/module/src/data_context.rs b/lib/module/src/data_context.rs index 510b549e90..51eac88b79 100644 --- a/lib/module/src/data_context.rs +++ b/lib/module/src/data_context.rs @@ -144,7 +144,7 @@ mod tests { fn basic_data_context() { let mut data_ctx = DataContext::new(); { - let description = data_ctx.description(); + let description = &data_ctx.description; assert_eq!(description.writable, Writability::Readonly); assert_eq!(description.init, Init::Uninitialized); assert!(description.function_decls.is_empty()); @@ -177,7 +177,7 @@ mod tests { data_ctx.clear(); { - let description = data_ctx.description(); + let description = &data_ctx.description; assert_eq!(description.writable, Writability::Readonly); assert_eq!(description.init, Init::Uninitialized); assert!(description.function_decls.is_empty());