Skip to content

Commit 2c31fe3

Browse files
committed
test(toml): Show underscore behavior for bin targets
1 parent d59e7a3 commit 2c31fe3

File tree

1 file changed

+191
-0
lines changed

1 file changed

+191
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 191 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1136,6 +1136,100 @@ fn lib_crate_type2_conflict() {
11361136
.run();
11371137
}
11381138

1139+
#[cargo_test]
1140+
fn bin_crate_type2() {
1141+
let p = project()
1142+
.file(
1143+
"Cargo.toml",
1144+
r#"
1145+
[package]
1146+
name = "foo"
1147+
version = "0.5.0"
1148+
edition = "2015"
1149+
authors = ["wycats@example.com"]
1150+
1151+
[[bin]]
1152+
name = "foo"
1153+
path = "src/main.rs"
1154+
crate_type = []
1155+
"#,
1156+
)
1157+
.file("src/main.rs", "fn main() {}")
1158+
.build();
1159+
p.cargo("check")
1160+
.with_stderr(
1161+
"\
1162+
[CHECKING] foo v0.5.0 ([CWD])
1163+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
1164+
",
1165+
)
1166+
.run();
1167+
}
1168+
1169+
#[cargo_test(nightly, reason = "edition2024 is not stable")]
1170+
fn bin_crate_type2_2024() {
1171+
let p = project()
1172+
.file(
1173+
"Cargo.toml",
1174+
r#"
1175+
cargo-features = ["edition2024"]
1176+
1177+
[package]
1178+
name = "foo"
1179+
version = "0.5.0"
1180+
edition = "2024"
1181+
authors = ["wycats@example.com"]
1182+
1183+
[[bin]]
1184+
name = "foo"
1185+
path = "src/main.rs"
1186+
crate_type = []
1187+
"#,
1188+
)
1189+
.file("src/main.rs", "fn main() {}")
1190+
.build();
1191+
p.cargo("check")
1192+
.masquerade_as_nightly_cargo(&["edition2024"])
1193+
.with_stderr(
1194+
"\
1195+
[CHECKING] foo v0.5.0 ([CWD])
1196+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
1197+
",
1198+
)
1199+
.run();
1200+
}
1201+
1202+
#[cargo_test]
1203+
fn bin_crate_type2_conflict() {
1204+
let p = project()
1205+
.file(
1206+
"Cargo.toml",
1207+
r#"
1208+
[package]
1209+
name = "foo"
1210+
version = "0.5.0"
1211+
edition = "2015"
1212+
authors = ["wycats@example.com"]
1213+
1214+
[[bin]]
1215+
name = "foo"
1216+
path = "src/main.rs"
1217+
crate_type = []
1218+
crate-type = []
1219+
"#,
1220+
)
1221+
.file("src/main.rs", "fn main() {}")
1222+
.build();
1223+
p.cargo("check")
1224+
.with_stderr(
1225+
"\
1226+
[CHECKING] foo v0.5.0 ([CWD])
1227+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
1228+
",
1229+
)
1230+
.run();
1231+
}
1232+
11391233
#[cargo_test]
11401234
fn examples_crate_type2() {
11411235
let p = project()
@@ -1939,6 +2033,103 @@ fn lib_proc_macro2_conflict() {
19392033
.run();
19402034
}
19412035

2036+
#[cargo_test]
2037+
fn bin_proc_macro2() {
2038+
let foo = project()
2039+
.file(
2040+
"Cargo.toml",
2041+
r#"
2042+
[package]
2043+
name = "foo"
2044+
version = "0.5.0"
2045+
edition = "2015"
2046+
authors = ["wycats@example.com"]
2047+
2048+
[[bin]]
2049+
name = "foo"
2050+
path = "src/main.rs"
2051+
proc_macro = false
2052+
"#,
2053+
)
2054+
.file("src/main.rs", "fn main() {}")
2055+
.build();
2056+
2057+
foo.cargo("check")
2058+
.with_stderr(
2059+
"\
2060+
[CHECKING] foo v0.5.0 ([CWD])
2061+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
2062+
",
2063+
)
2064+
.run();
2065+
}
2066+
2067+
#[cargo_test(nightly, reason = "edition2024 is not stable")]
2068+
fn bin_proc_macro2_2024() {
2069+
let foo = project()
2070+
.file(
2071+
"Cargo.toml",
2072+
r#"
2073+
cargo-features = ["edition2024"]
2074+
2075+
[package]
2076+
name = "foo"
2077+
version = "0.5.0"
2078+
edition = "2015"
2079+
authors = ["wycats@example.com"]
2080+
2081+
[[bin]]
2082+
name = "foo"
2083+
path = "src/main.rs"
2084+
proc_macro = false
2085+
"#,
2086+
)
2087+
.file("src/main.rs", "fn main() {}")
2088+
.build();
2089+
2090+
foo.cargo("check")
2091+
.masquerade_as_nightly_cargo(&["edition2024"])
2092+
.with_stderr(
2093+
"\
2094+
[CHECKING] foo v0.5.0 ([CWD])
2095+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
2096+
",
2097+
)
2098+
.run();
2099+
}
2100+
2101+
#[cargo_test]
2102+
fn bin_proc_macro2_conflict() {
2103+
let foo = project()
2104+
.file(
2105+
"Cargo.toml",
2106+
r#"
2107+
[package]
2108+
name = "foo"
2109+
version = "0.5.0"
2110+
edition = "2015"
2111+
authors = ["wycats@example.com"]
2112+
2113+
[[bin]]
2114+
name = "foo"
2115+
path = "src/main.rs"
2116+
proc-macro = false
2117+
proc_macro = false
2118+
"#,
2119+
)
2120+
.file("src/main.rs", "fn main() {}")
2121+
.build();
2122+
2123+
foo.cargo("check")
2124+
.with_stderr(
2125+
"\
2126+
[CHECKING] foo v0.5.0 ([CWD])
2127+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]s
2128+
",
2129+
)
2130+
.run();
2131+
}
2132+
19422133
#[cargo_test]
19432134
fn invalid_toml_historically_allowed_fails() {
19442135
let p = project()

0 commit comments

Comments
 (0)