Skip to content

Commit dfaba34

Browse files
committed
Auto merge of #5513 - ehuss:test-binary-panic, r=alexcrichton
Fix `panic` for binaries built during tests. Fixes #5435 Also re-enable tests now that #5460 has landed.
2 parents 1fd81a5 + 3071734 commit dfaba34

File tree

2 files changed

+35
-41
lines changed

2 files changed

+35
-41
lines changed

src/cargo/core/compiler/context/unit_dependencies.rs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -168,21 +168,15 @@ fn compute_deps<'a, 'b, 'cfg>(
168168
})
169169
.map(|t| {
170170
(
171-
// TODO: Should not be using profile_for here. Should
172-
// instead use ProfileFor::Any so that bins are built
173-
// with panic, but this aggravates
174-
// https://github.com/rust-lang/cargo/issues/5444
175-
// Switching it will fix
176-
// https://github.com/rust-lang/cargo/issues/5435
177171
new_unit(
178172
bcx,
179173
unit.pkg,
180174
t,
181-
profile_for,
175+
ProfileFor::Any,
182176
unit.kind.for_target(t),
183177
CompileMode::Build,
184178
),
185-
profile_for,
179+
ProfileFor::Any,
186180
)
187181
}),
188182
);

tests/testsuite/profile_targets.rs

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -144,9 +144,6 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
144144
);
145145
}
146146

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

227-
// Temporarily disable this test until --all-targets is fixed when using
228-
// `panic`. See https://github.com/rust-lang/cargo/issues/5444
229-
#[ignore]
230224
#[test]
231225
fn profile_selection_build_all_targets_release() {
232226
let p = all_target_project();
@@ -315,12 +309,13 @@ fn profile_selection_test() {
315309
// - foo target list is:
316310
// Target Profile Mode
317311
// ------ ------- ----
318-
// lib dev-panic build
312+
// lib dev-panic build (for tests)
313+
// lib dev build (for bins)
319314
// lib test test
320315
// test test test
321316
// example dev-panic build
322317
// bin test test
323-
// bin dev-panic build
318+
// bin dev build
324319
//
325320
assert_that(p.cargo("test -vv"), execs().with_status(0).with_stderr_unordered("\
326321
[COMPILING] bar [..]
@@ -332,16 +327,17 @@ fn profile_selection_test() {
332327
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
333328
[RUNNING] `[..][/]target[/]debug[/]build[/]foo-[..][/]build-script-build`
334329
foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
330+
[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 [..]
335331
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
336332
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
337333
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
338334
[RUNNING] `rustc --crate-name ex1 examples[/]ex1.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
339335
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C codegen-units=3 -C debuginfo=2 --test [..]
340-
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C codegen-units=1 -C debuginfo=2 [..]
336+
[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 [..]
341337
[FINISHED] dev [unoptimized + debuginfo] [..]
342-
[RUNNING] `[..]foo[..]`
343-
[RUNNING] `[..]foo[..]`
344-
[RUNNING] `[..]test1[..]`
338+
[RUNNING] `[..][/]deps[/]foo-[..]`
339+
[RUNNING] `[..][/]deps[/]foo-[..]`
340+
[RUNNING] `[..][/]deps[/]test1-[..]`
345341
[DOCTEST] foo
346342
[RUNNING] `rustdoc --test [..]
347343
"));
@@ -353,9 +349,9 @@ foo custom build PROFILE=debug DEBUG=true OPT_LEVEL=0
353349
[FRESH] bdep [..]
354350
[FRESH] foo [..]
355351
[FINISHED] dev [unoptimized + debuginfo] [..]
356-
[RUNNING] `[..]foo[..]`
357-
[RUNNING] `[..]foo[..]`
358-
[RUNNING] `[..]test1[..]`
352+
[RUNNING] `[..][/]deps[/]foo-[..]`
353+
[RUNNING] `[..][/]deps[/]foo-[..]`
354+
[RUNNING] `[..][/]deps[/]test1-[..]`
359355
[DOCTEST] foo
360356
[RUNNING] `rustdoc --test [..]
361357
",
@@ -381,12 +377,13 @@ fn profile_selection_test_release() {
381377
// - foo target list is:
382378
// Target Profile Mode
383379
// ------ ------- ----
384-
// lib release-panic build
380+
// lib release-panic build (for tests)
381+
// lib release build (for bins)
385382
// lib bench test
386383
// test bench test
387384
// example release-panic build
388385
// bin bench test
389-
// bin release-panic build
386+
// bin release build
390387
//
391388
assert_that(p.cargo("test --release -vv"), execs().with_status(0).with_stderr_unordered("\
392389
[COMPILING] bar [..]
@@ -398,16 +395,17 @@ fn profile_selection_test_release() {
398395
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
399396
[RUNNING] `[..][/]target[/]release[/]build[/]foo-[..][/]build-script-build`
400397
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
398+
[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 [..]
401399
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
402400
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
403401
[RUNNING] `rustc --crate-name test1 tests[/]test1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
404402
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
405403
[RUNNING] `rustc --crate-name ex1 examples[/]ex1.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
406-
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
404+
[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 [..]
407405
[FINISHED] release [optimized] [..]
408-
[RUNNING] `[..]foo[..]`
409-
[RUNNING] `[..]foo[..]`
410-
[RUNNING] `[..]test1[..]`
406+
[RUNNING] `[..][/]deps[/]foo-[..]`
407+
[RUNNING] `[..][/]deps[/]foo-[..]`
408+
[RUNNING] `[..][/]deps[/]test1-[..]`
411409
[DOCTEST] foo
412410
[RUNNING] `rustdoc --test [..]`
413411
"));
@@ -419,9 +417,9 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
419417
[FRESH] bdep [..]
420418
[FRESH] foo [..]
421419
[FINISHED] release [optimized] [..]
422-
[RUNNING] `[..]foo[..]`
423-
[RUNNING] `[..]foo[..]`
424-
[RUNNING] `[..]test1[..]`
420+
[RUNNING] `[..][/]deps[/]foo-[..]`
421+
[RUNNING] `[..][/]deps[/]foo-[..]`
422+
[RUNNING] `[..][/]deps[/]test1-[..]`
425423
[DOCTEST] foo
426424
[RUNNING] `rustdoc --test [..]
427425
",
@@ -448,11 +446,12 @@ fn profile_selection_bench() {
448446
// - foo target list is:
449447
// Target Profile Mode
450448
// ------ ------- ----
451-
// lib release-panic build
449+
// lib release-panic build (for benches)
450+
// lib release build (for bins)
452451
// lib bench test(bench)
453452
// bench bench test(bench)
454453
// bin bench test(bench)
455-
// bin release-panic build
454+
// bin release build
456455
//
457456
assert_that(p.cargo("bench -vv"), execs().with_status(0).with_stderr_unordered("\
458457
[COMPILING] bar [..]
@@ -464,15 +463,16 @@ fn profile_selection_bench() {
464463
[RUNNING] `rustc --crate-name build_script_build build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
465464
[RUNNING] `[..]target[/]release[/]build[/]foo-[..][/]build-script-build`
466465
foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
466+
[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 [..]
467467
[RUNNING] `rustc --crate-name foo src[/]lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
468468
[RUNNING] `rustc --crate-name foo src[/]lib.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
469469
[RUNNING] `rustc --crate-name bench1 benches[/]bench1.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
470470
[RUNNING] `rustc --crate-name foo src[/]main.rs --emit=dep-info,link -C opt-level=3 -C codegen-units=4 --test [..]
471-
[RUNNING] `rustc --crate-name foo src[/]main.rs --crate-type bin --emit=dep-info,link -C opt-level=3 -C codegen-units=2 [..]
471+
[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 [..]
472472
[FINISHED] release [optimized] [..]
473-
[RUNNING] `[..]foo[..] --bench`
474-
[RUNNING] `[..]foo[..] --bench`
475-
[RUNNING] `[..]bench1[..] --bench`
473+
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
474+
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
475+
[RUNNING] `[..][/]deps[/]bench1-[..] --bench`
476476
"));
477477
assert_that(
478478
p.cargo("bench -vv"),
@@ -482,9 +482,9 @@ foo custom build PROFILE=release DEBUG=false OPT_LEVEL=3
482482
[FRESH] bdep [..]
483483
[FRESH] foo [..]
484484
[FINISHED] release [optimized] [..]
485-
[RUNNING] `[..]foo[..] --bench`
486-
[RUNNING] `[..]foo[..] --bench`
487-
[RUNNING] `[..]bench1[..] --bench`
485+
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
486+
[RUNNING] `[..][/]deps[/]foo-[..] --bench`
487+
[RUNNING] `[..][/]deps[/]bench1-[..] --bench`
488488
",
489489
),
490490
);

0 commit comments

Comments
 (0)