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

Fix panic for binaries built during tests. #5513

Merged
merged 1 commit into from
May 10, 2018
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
10 changes: 2 additions & 8 deletions src/cargo/core/compiler/context/unit_dependencies.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,21 +168,15 @@ fn compute_deps<'a, 'b, 'cfg>(
})
.map(|t| {
(
// TODO: Should not be using profile_for here. Should
// instead use ProfileFor::Any so that bins are built
// with panic, but this aggravates
// https://github.com/rust-lang/cargo/issues/5444
// Switching it will fix
// https://github.com/rust-lang/cargo/issues/5435
new_unit(
bcx,
unit.pkg,
t,
profile_for,
ProfileFor::Any,
unit.kind.for_target(t),
CompileMode::Build,
),
profile_for,
ProfileFor::Any,
)
}),
);
Expand Down
66 changes: 33 additions & 33 deletions tests/testsuite/profile_targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,6 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
);
}

// Temporarily disable this test until --all-targets is fixed when using
// `panic`. See https://github.com/rust-lang/cargo/issues/5444
#[ignore]
#[test]
fn profile_selection_build_all_targets() {
let p = all_target_project();
Expand Down Expand Up @@ -224,9 +221,6 @@ foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
);
}

// Temporarily disable this test until --all-targets is fixed when using
// `panic`. See https://github.com/rust-lang/cargo/issues/5444
#[ignore]
#[test]
fn profile_selection_build_all_targets_release() {
let p = all_target_project();
Expand Down Expand Up @@ -315,12 +309,13 @@ fn profile_selection_test() {
// - foo target list is:
// Target Profile Mode
// ------ ------- ----
// lib dev-panic build
// lib dev-panic build (for tests)
// lib dev build (for bins)
// lib test test
// test test test
// example dev-panic build
// bin test test
// bin dev-panic build
// bin dev build
//
assert_that(p.cargo("test -vv"), execs().with_status(0).with_stderr_unordered("\
[COMPILING] bar [..]
Expand All @@ -332,16 +327,17 @@ fn profile_selection_test() {
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `[..][/]target[/]debug[/]build[/]foo-[..][/]build-script-build`
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
[RUNNING] `rustc --crate-name ex1 examples[/]ex1.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C panic=abort -C codegen-units=1 -C debuginfo=2 [..]
[FINISHED] dev [unoptimized + debuginfo] [..]
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]test1[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]test1-[..]`
[DOCTEST] foo
[RUNNING] `rustdoc --test [..]
"));
Expand All @@ -353,9 +349,9 @@ foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
[FRESH] bdep [..]
[FRESH] foo [..]
[FINISHED] dev [unoptimized + debuginfo] [..]
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]test1[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]test1-[..]`
[DOCTEST] foo
[RUNNING] `rustdoc --test [..]
",
Expand All @@ -381,12 +377,13 @@ fn profile_selection_test_release() {
// - foo target list is:
// Target Profile Mode
// ------ ------- ----
// lib release-panic build
// lib release-panic build (for tests)
// lib release build (for bins)
// lib bench test
// test bench test
// example release-panic build
// bin bench test
// bin release-panic build
// bin release build
//
assert_that(p.cargo("test --release -vv"), execs().with_status(0).with_stderr_unordered("\
[COMPILING] bar [..]
Expand All @@ -398,16 +395,17 @@ fn profile_selection_test_release() {
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..][/]target[/]release[/]build[/]foo-[..][/]build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name ex1 examples[/]ex1.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[FINISHED] release [optimized] [..]
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]test1[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]test1-[..]`
[DOCTEST] foo
[RUNNING] `rustdoc --test [..]`
"));
Expand All @@ -419,9 +417,9 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[FRESH] bdep [..]
[FRESH] foo [..]
[FINISHED] release [optimized] [..]
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]foo[..]`
[RUNNING] `[..]test1[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]foo-[..]`
[RUNNING] `[..][/]deps[/]test1-[..]`
[DOCTEST] foo
[RUNNING] `rustdoc --test [..]
",
Expand All @@ -448,11 +446,12 @@ fn profile_selection_bench() {
// - foo target list is:
// Target Profile Mode
// ------ ------- ----
// lib release-panic build
// lib release-panic build (for benches)
// lib release build (for bins)
// lib bench test(bench)
// bench bench test(bench)
// bin bench test(bench)
// bin release-panic build
// bin release build
//
assert_that(p.cargo("bench -vv"), execs().with_status(0).with_stderr_unordered("\
[COMPILING] bar [..]
Expand All @@ -464,15 +463,16 @@ fn profile_selection_bench() {
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `[..]target[/]release[/]build[/]foo-[..][/]build-script-build`
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name bench1 benches[/]bench1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C panic=abort -C codegen-units=2 [..]
[FINISHED] release [optimized] [..]
[RUNNING] `[..]foo[..] --bench`
[RUNNING] `[..]foo[..] --bench`
[RUNNING] `[..]bench1[..] --bench`
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
[RUNNING] `[..][/]deps[/]bench1-[..] --bench`
"));
assert_that(
p.cargo("bench -vv"),
Expand All @@ -482,9 +482,9 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
[FRESH] bdep [..]
[FRESH] foo [..]
[FINISHED] release [optimized] [..]
[RUNNING] `[..]foo[..] --bench`
[RUNNING] `[..]foo[..] --bench`
[RUNNING] `[..]bench1[..] --bench`
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
[RUNNING] `[..][/]deps[/]bench1-[..] --bench`
",
),
);
Expand Down