Skip to content

Commit 6fcbeb5

Browse files
committed
Check in test
1 parent e09e887 commit 6fcbeb5

File tree

1 file changed

+121
-0
lines changed

1 file changed

+121
-0
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
//! Tests for `panic = "immediate-abort"`.
2+
3+
use crate::prelude::*;
4+
use cargo_test_support::project;
5+
use cargo_test_support::str;
6+
7+
#[cargo_test]
8+
fn gated_manifest() {
9+
let p = project()
10+
.file(
11+
"Cargo.toml",
12+
r#"
13+
[package]
14+
name = "foo"
15+
version = "0.0.1"
16+
edition = "2015"
17+
18+
[profile.dev]
19+
panic = "immediate-abort"
20+
"#,
21+
)
22+
.file("src/lib.rs", "")
23+
.build();
24+
25+
p.cargo("check")
26+
.masquerade_as_nightly_cargo(&["panic-immediate-abort"])
27+
.with_status(101)
28+
.with_stderr_data(str![[r#"
29+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
30+
31+
Caused by:
32+
feature `panic-immediate-abort` is required
33+
...
34+
"#]])
35+
.run();
36+
}
37+
38+
#[cargo_test]
39+
fn gated_config_toml() {
40+
let p = project()
41+
.file(
42+
".cargo/config.toml",
43+
r#"
44+
[profile.dev]
45+
panic = "immediate-abort"
46+
"#,
47+
)
48+
.file("src/lib.rs", "")
49+
.build();
50+
51+
p.cargo("check")
52+
.masquerade_as_nightly_cargo(&["panic-immediate-abort"])
53+
.with_status(101)
54+
.with_stderr_data(str![[r#"
55+
[ERROR] config profile `dev` is not valid (defined in `[ROOT]/foo/.cargo/config.toml`)
56+
57+
Caused by:
58+
feature `panic-immediate-abort` is required
59+
...
60+
"#]])
61+
.run();
62+
}
63+
64+
#[cargo_test(nightly, reason = "-Cpanic=immediate-abort is unstable")]
65+
fn manifest_gate_works() {
66+
let p = project()
67+
.file(
68+
"Cargo.toml",
69+
r#"
70+
cargo-features = ["panic-immediate-abort"]
71+
[package]
72+
name = "foo"
73+
version = "0.0.1"
74+
edition = "2015"
75+
76+
[profile.dev]
77+
panic = "immediate-abort"
78+
"#,
79+
)
80+
.file("src/lib.rs", "")
81+
.build();
82+
83+
p.cargo("build --verbose")
84+
.masquerade_as_nightly_cargo(&["panic-immediate-abort"])
85+
.with_stderr_data(str![[r#"
86+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
87+
[RUNNING] `rustc [..]-C panic=immediate-abort -Z unstable-options[..]`
88+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
89+
90+
"#]])
91+
.run();
92+
}
93+
94+
#[cargo_test(nightly, reason = "-Cpanic=immediate-abort is unstable")]
95+
fn cli_gate_works() {
96+
let p = project()
97+
.file(
98+
"Cargo.toml",
99+
r#"
100+
[package]
101+
name = "foo"
102+
version = "0.0.1"
103+
edition = "2015"
104+
105+
[profile.dev]
106+
panic = "immediate-abort"
107+
"#,
108+
)
109+
.file("src/lib.rs", "")
110+
.build();
111+
112+
p.cargo("build --verbose -Z panic-immediate-abort")
113+
.masquerade_as_nightly_cargo(&["panic-immediate-abort"])
114+
.with_stderr_data(str![[r#"
115+
[COMPILING] foo v0.0.1 ([ROOT]/foo)
116+
[RUNNING] `rustc [..]-C panic=immediate-abort -Z unstable-options[..]`
117+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
118+
119+
"#]])
120+
.run();
121+
}

0 commit comments

Comments
 (0)