Skip to content

Commit 868662c

Browse files
committed
test(toml): Show underscore field behavior
1 parent 208d10d commit 868662c

File tree

1 file changed

+291
-0
lines changed

1 file changed

+291
-0
lines changed

tests/testsuite/bad_config.rs

Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -804,6 +804,42 @@ Caused by:
804804
.run();
805805
}
806806

807+
#[cargo_test]
808+
fn dev_dependencies2() {
809+
let p = project()
810+
.file(
811+
"Cargo.toml",
812+
r#"
813+
[package]
814+
name = "foo"
815+
version = "0.1.0"
816+
edition = "2018"
817+
818+
[dev_dependencies]
819+
a = {path = "a"}
820+
"#,
821+
)
822+
.file("src/lib.rs", "")
823+
.file(
824+
"a/Cargo.toml",
825+
r#"
826+
[package]
827+
name = "a"
828+
version = "0.0.1"
829+
edition = "2015"
830+
"#,
831+
)
832+
.file("a/src/lib.rs", "")
833+
.build();
834+
p.cargo("check")
835+
.with_stderr_does_not_contain(
836+
"\
837+
[WARNING] [..]
838+
",
839+
)
840+
.run();
841+
}
842+
807843
#[cargo_test]
808844
fn dev_dependencies2_conflict() {
809845
let p = project()
@@ -842,6 +878,42 @@ fn dev_dependencies2_conflict() {
842878
.run();
843879
}
844880

881+
#[cargo_test]
882+
fn build_dependencies2() {
883+
let p = project()
884+
.file(
885+
"Cargo.toml",
886+
r#"
887+
[package]
888+
name = "foo"
889+
version = "0.1.0"
890+
edition = "2018"
891+
892+
[build_dependencies]
893+
a = {path = "a"}
894+
"#,
895+
)
896+
.file("src/lib.rs", "")
897+
.file(
898+
"a/Cargo.toml",
899+
r#"
900+
[package]
901+
name = "a"
902+
version = "0.0.1"
903+
edition = "2015"
904+
"#,
905+
)
906+
.file("a/src/lib.rs", "")
907+
.build();
908+
p.cargo("check")
909+
.with_stderr_does_not_contain(
910+
"\
911+
[WARNING] [..]
912+
",
913+
)
914+
.run();
915+
}
916+
845917
#[cargo_test]
846918
fn build_dependencies2_conflict() {
847919
let p = project()
@@ -880,6 +952,34 @@ fn build_dependencies2_conflict() {
880952
.run();
881953
}
882954

955+
#[cargo_test]
956+
fn lib_crate_type2() {
957+
let p = project()
958+
.file(
959+
"Cargo.toml",
960+
r#"
961+
[package]
962+
name = "foo"
963+
version = "0.5.0"
964+
edition = "2015"
965+
authors = ["[email protected]"]
966+
967+
[lib]
968+
name = "foo"
969+
crate_type = ["staticlib", "dylib"]
970+
"#,
971+
)
972+
.file("src/lib.rs", "pub fn foo() {}")
973+
.build();
974+
p.cargo("check")
975+
.with_stderr_does_not_contain(
976+
"\
977+
[WARNING] [..]
978+
",
979+
)
980+
.run();
981+
}
982+
883983
#[cargo_test]
884984
fn lib_crate_type2_conflict() {
885985
let p = project()
@@ -909,6 +1009,51 @@ fn lib_crate_type2_conflict() {
9091009
.run();
9101010
}
9111011

1012+
#[cargo_test]
1013+
fn examples_crate_type2() {
1014+
let p = project()
1015+
.file(
1016+
"Cargo.toml",
1017+
r#"
1018+
[package]
1019+
name = "foo"
1020+
version = "0.5.0"
1021+
edition = "2015"
1022+
authors = ["[email protected]"]
1023+
1024+
[[example]]
1025+
name = "ex"
1026+
path = "examples/ex.rs"
1027+
crate_type = ["proc_macro"]
1028+
[[example]]
1029+
name = "goodbye"
1030+
path = "examples/ex-goodbye.rs"
1031+
crate_type = ["rlib", "staticlib"]
1032+
"#,
1033+
)
1034+
.file("src/lib.rs", "")
1035+
.file(
1036+
"examples/ex.rs",
1037+
r#"
1038+
fn main() { println!("ex"); }
1039+
"#,
1040+
)
1041+
.file(
1042+
"examples/ex-goodbye.rs",
1043+
r#"
1044+
fn main() { println!("goodbye"); }
1045+
"#,
1046+
)
1047+
.build();
1048+
p.cargo("check")
1049+
.with_stderr_does_not_contain(
1050+
"\
1051+
[WARNING] [..]
1052+
",
1053+
)
1054+
.run();
1055+
}
1056+
9121057
#[cargo_test]
9131058
fn examples_crate_type2_conflict() {
9141059
let p = project()
@@ -957,6 +1102,45 @@ fn examples_crate_type2_conflict() {
9571102
.run();
9581103
}
9591104

1105+
#[cargo_test]
1106+
fn cargo_platform_build_dependencies2() {
1107+
let host = rustc_host();
1108+
let p = project()
1109+
.file(
1110+
"Cargo.toml",
1111+
&format!(
1112+
r#"
1113+
[package]
1114+
name = "foo"
1115+
version = "0.5.0"
1116+
edition = "2015"
1117+
authors = ["[email protected]"]
1118+
build = "build.rs"
1119+
1120+
[target.{host}.build_dependencies]
1121+
build = {{ path = "build" }}
1122+
"#,
1123+
host = host
1124+
),
1125+
)
1126+
.file("src/main.rs", "fn main() { }")
1127+
.file(
1128+
"build.rs",
1129+
"extern crate build; fn main() { build::build(); }",
1130+
)
1131+
.file("build/Cargo.toml", &basic_manifest("build", "0.5.0"))
1132+
.file("build/src/lib.rs", "pub fn build() {}")
1133+
.build();
1134+
1135+
p.cargo("check")
1136+
.with_stderr_does_not_contain(
1137+
"\
1138+
[WARNING] [..]
1139+
",
1140+
)
1141+
.run();
1142+
}
1143+
9601144
#[cargo_test]
9611145
fn cargo_platform_build_dependencies2_conflict() {
9621146
let host = rustc_host();
@@ -998,6 +1182,44 @@ fn cargo_platform_build_dependencies2_conflict() {
9981182
.run();
9991183
}
10001184

1185+
#[cargo_test]
1186+
fn cargo_platform_dev_dependencies2() {
1187+
let host = rustc_host();
1188+
let p = project()
1189+
.file(
1190+
"Cargo.toml",
1191+
&format!(
1192+
r#"
1193+
[package]
1194+
name = "foo"
1195+
version = "0.5.0"
1196+
edition = "2015"
1197+
authors = ["[email protected]"]
1198+
1199+
[target.{host}.dev_dependencies]
1200+
dev = {{ path = "dev" }}
1201+
"#,
1202+
host = host
1203+
),
1204+
)
1205+
.file("src/main.rs", "fn main() { }")
1206+
.file(
1207+
"tests/foo.rs",
1208+
"extern crate dev; #[test] fn foo() { dev::dev() }",
1209+
)
1210+
.file("dev/Cargo.toml", &basic_manifest("dev", "0.5.0"))
1211+
.file("dev/src/lib.rs", "pub fn dev() {}")
1212+
.build();
1213+
1214+
p.cargo("check")
1215+
.with_stderr_does_not_contain(
1216+
"\
1217+
[WARNING] [..]
1218+
",
1219+
)
1220+
.run();
1221+
}
1222+
10011223
#[cargo_test]
10021224
fn cargo_platform_dev_dependencies2_conflict() {
10031225
let host = rustc_host();
@@ -1038,6 +1260,49 @@ fn cargo_platform_dev_dependencies2_conflict() {
10381260
.run();
10391261
}
10401262

1263+
#[cargo_test]
1264+
fn default_features2() {
1265+
let p = project()
1266+
.file(
1267+
"Cargo.toml",
1268+
r#"
1269+
[package]
1270+
name = "foo"
1271+
version = "0.1.0"
1272+
edition = "2015"
1273+
authors = []
1274+
1275+
[dependencies]
1276+
a = { path = "a", features = ["f1"], default_features = false }
1277+
"#,
1278+
)
1279+
.file("src/lib.rs", "")
1280+
.file(
1281+
"a/Cargo.toml",
1282+
r#"
1283+
[package]
1284+
name = "a"
1285+
version = "0.1.0"
1286+
edition = "2015"
1287+
authors = []
1288+
1289+
[features]
1290+
default = ["f1"]
1291+
f1 = []
1292+
"#,
1293+
)
1294+
.file("a/src/lib.rs", "")
1295+
.build();
1296+
1297+
p.cargo("check")
1298+
.with_stderr_does_not_contain(
1299+
"\
1300+
[WARNING] [..]
1301+
",
1302+
)
1303+
.run();
1304+
}
1305+
10411306
#[cargo_test]
10421307
fn default_features2_conflict() {
10431308
let p = project()
@@ -1081,6 +1346,32 @@ fn default_features2_conflict() {
10811346
.run();
10821347
}
10831348

1349+
#[cargo_test]
1350+
fn proc_macro2() {
1351+
let foo = project()
1352+
.file(
1353+
"Cargo.toml",
1354+
r#"
1355+
[package]
1356+
name = "foo"
1357+
version = "0.1.0"
1358+
edition = "2015"
1359+
[lib]
1360+
proc_macro = true
1361+
"#,
1362+
)
1363+
.file("src/lib.rs", "")
1364+
.build();
1365+
1366+
foo.cargo("check")
1367+
.with_stderr_does_not_contain(
1368+
"\
1369+
[WARNING] [..]
1370+
",
1371+
)
1372+
.run();
1373+
}
1374+
10841375
#[cargo_test]
10851376
fn proc_macro2_conflict() {
10861377
let foo = project()

0 commit comments

Comments
 (0)