Skip to content

Commit

Permalink
Fix transitive doctests panic=abort
Browse files Browse the repository at this point in the history
Ensure that when we compile doctested libraries or examples we use the same
panic mode as the rest of the tests, namely ignoring panic=abort b/c libtest
isn't compiled with panic=abort.

Closes #3017
  • Loading branch information
alexcrichton committed Aug 19, 2016
1 parent 9945504 commit 23498ec
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/cargo/ops/cargo_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -308,17 +308,22 @@ fn generate_targets<'a>(pkg: &'a Package,
}).collect::<Vec<_>>())
}
CompileMode::Test => {
let deps = if release {
&profiles.bench_deps
} else {
&profiles.test_deps
};
let mut base = pkg.targets().iter().filter(|t| {
t.tested()
}).map(|t| {
(t, if t.is_example() {build} else {profile})
(t, if t.is_example() {deps} else {profile})
}).collect::<Vec<_>>();

// Always compile the library if we're testing everything as
// it'll be needed for doctests
if let Some(t) = pkg.targets().iter().find(|t| t.is_lib()) {
if t.doctested() {
base.push((t, build));
base.push((t, deps));
}
}
Ok(base)
Expand Down
30 changes: 30 additions & 0 deletions tests/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2232,3 +2232,33 @@ fn cfg_test_even_with_no_harness() {
[RUNNING] `[..]`
"));
}

#[test]
fn panic_abort_multiple() {
let p = project("foo")
.file("Cargo.toml", r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
a = { path = "a" }
[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", "");
assert_that(p.cargo_process("test")
.arg("--release").arg("-v")
.arg("-p").arg("foo")
.arg("-p").arg("a"),
execs().with_status(0));
}

0 comments on commit 23498ec

Please sign in to comment.