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

Ignore panic configuration for test/bench profiles #3175

Merged
merged 1 commit into from
Nov 3, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ pub fn compile_ws<'a>(ws: &Workspace<'a>,
let _p = profile::start("compiling");
let mut build_config = try!(scrape_build_config(config, jobs, target));
build_config.release = release;
build_config.test = mode == CompileMode::Test;
build_config.test = mode == CompileMode::Test || mode == CompileMode::Bench;
build_config.json_errors = message_format == MessageFormat::Json;
if let CompileMode::Doc { deps } = mode {
build_config.doc_all = deps;
Expand Down
4 changes: 4 additions & 0 deletions src/cargo/util/toml.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,10 @@ fn build_profiles(profiles: &Option<TomlProfiles>) -> Profiles {
profiles.and_then(|p| p.doc.as_ref())),
custom_build: Profile::default_custom_build(),
};
// The test/bench targets cannot have panic=abort because they'll all get
// compiled with --test which requires the unwind runtime currently
profiles.test.panic = None;
profiles.bench.panic = None;
profiles.test_deps.panic = None;
profiles.bench_deps.panic = None;
return profiles;
Expand Down
32 changes: 32 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2332,3 +2332,35 @@ fn pass_correct_cfgs_flags_to_rustdoc() {
[DOCTEST] foo
[RUNNING] `rustdoc --test [..]feature_a[..]`"));
}

#[test]
fn test_release_ignore_panic() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
a = { path = "a" }
[profile.test]
panic = 'abort'
[profile.release]
panic = 'abort'
"#)
.file("src/lib.rs", "extern crate a;")
.file("a/Cargo.toml", r#"
[package]
name = "a"
version = "0.0.1"
authors = []
"#)
.file("a/src/lib.rs", "");
p.build();
println!("test");
assert_that(p.cargo("test").arg("-v"), execs().with_status(0));
println!("bench");
assert_that(p.cargo("bench").arg("-v"), execs().with_status(0));
}