Skip to content

Commit 8a388b0

Browse files
committed
test(test): ensure panic=abort not added to default example inclusion
`cargo test` will implicitly build examples as examples binaries (without --test) by default, when no target selection flags provided. We don't have test exercising this, so add one.
1 parent d0cbbac commit 8a388b0

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

tests/testsuite/test.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1831,6 +1831,9 @@ fn test_run_implicit_example_target() {
18311831
[[example]]
18321832
name = "myexm2"
18331833
test = true
1834+
1835+
[profile.test]
1836+
panic = "abort" # this should be ignored by default Cargo targets set.
18341837
"#,
18351838
)
18361839
.file(
@@ -1852,11 +1855,13 @@ fn test_run_implicit_example_target() {
18521855
)
18531856
.build();
18541857

1855-
// Compiles myexm1 as normal, but does not run it.
1858+
// Compiles myexm1 as normal binary (without --test), but does not run it.
18561859
prj.cargo("test -v")
18571860
.with_stderr_contains("[RUNNING] `rustc [..]myexm1.rs [..]--crate-type bin[..]")
18581861
.with_stderr_contains("[RUNNING] `rustc [..]myexm2.rs [..]--test[..]")
18591862
.with_stderr_does_not_contain("[RUNNING] [..]myexm1-[..]")
1863+
// profile.test panic settings shouldn't be applied even to myexm1
1864+
.with_stderr_line_without(&["[RUNNING] `rustc --crate-name myexm1"], &["panic=abort"])
18601865
.with_stderr_contains("[RUNNING] [..]target/debug/examples/myexm2-[..]")
18611866
.run();
18621867

0 commit comments

Comments
 (0)