Skip to content

Commit fcf1259

Browse files
committed
test(script): Show remaining workspace behavors
1 parent c00a07a commit fcf1259

File tree

1 file changed

+103
-0
lines changed

1 file changed

+103
-0
lines changed

tests/testsuite/script/cargo.rs

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,6 +1079,109 @@ Caused by:
10791079
.run();
10801080
}
10811081

1082+
#[cargo_test(nightly, reason = "-Zscript is unstable")]
1083+
fn workspace_members_mentions_script() {
1084+
let p = cargo_test_support::project()
1085+
.file(
1086+
"Cargo.toml",
1087+
r#"
1088+
[workspace]
1089+
members = ["scripts/nop.rs"]
1090+
"#,
1091+
)
1092+
.file(
1093+
"scripts/nop.rs",
1094+
r#"
1095+
----
1096+
package.edition = "2021"
1097+
----
1098+
1099+
fn main() {}
1100+
"#,
1101+
)
1102+
.build();
1103+
1104+
p.cargo("-Zscript check")
1105+
.masquerade_as_nightly_cargo(&["script"])
1106+
.with_status(101)
1107+
.with_stderr_data(str![[r#"
1108+
[ERROR] manifest path `[ROOT]/foo` contains no package: The manifest is virtual, and the workspace has no members.
1109+
1110+
"#]])
1111+
.run();
1112+
}
1113+
1114+
#[cargo_test(nightly, reason = "-Zscript is unstable")]
1115+
fn workspace_members_glob_matches_script() {
1116+
let p = cargo_test_support::project()
1117+
.file(
1118+
"Cargo.toml",
1119+
r#"
1120+
[workspace]
1121+
members = ["scripts/*"]
1122+
"#,
1123+
)
1124+
.file(
1125+
"scripts/nop.rs",
1126+
r#"
1127+
----
1128+
package.edition = "2021"
1129+
----
1130+
1131+
fn main() {}
1132+
"#,
1133+
)
1134+
.build();
1135+
1136+
p.cargo("-Zscript check")
1137+
.masquerade_as_nightly_cargo(&["script"])
1138+
.with_status(101)
1139+
.with_stderr_data(str![[r#"
1140+
[ERROR] manifest path `[ROOT]/foo` contains no package: The manifest is virtual, and the workspace has no members.
1141+
1142+
"#]])
1143+
.run();
1144+
}
1145+
1146+
#[cargo_test(nightly, reason = "-Zscript is unstable")]
1147+
fn package_workspace() {
1148+
let p = cargo_test_support::project()
1149+
.file(
1150+
"Cargo.toml",
1151+
r#"
1152+
[workspace]
1153+
members = ["scripts/*"]
1154+
1155+
[package]
1156+
name = "foo"
1157+
"#,
1158+
)
1159+
.file(
1160+
"scripts/nop.rs",
1161+
r#"
1162+
----
1163+
package.edition = "2021"
1164+
package.workspace = "../"
1165+
----
1166+
1167+
fn main() {}
1168+
"#,
1169+
)
1170+
.build();
1171+
1172+
p.cargo("-Zscript ./scripts/nop.rs")
1173+
.masquerade_as_nightly_cargo(&["script"])
1174+
.with_status(101)
1175+
.with_stderr_data(str![[r#"
1176+
[ERROR] failed to parse manifest at `[ROOT]/foo/scripts/nop.rs`
1177+
1178+
Caused by:
1179+
`package.workspace` is not allowed in embedded manifests
1180+
1181+
"#]])
1182+
.run();
1183+
}
1184+
10821185
#[cargo_test(nightly, reason = "-Zscript is unstable")]
10831186
fn disallow_explicit_lib() {
10841187
let p = cargo_test_support::project()

0 commit comments

Comments
 (0)