Skip to content

Commit aaaa37f

Browse files
committed
test(embedded): Add tests for unsupported commands
1 parent 445838d commit aaaa37f

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

tests/testsuite/script.rs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,3 +1182,62 @@ fn cmd_verify_project_with_embedded() {
11821182
)
11831183
.run();
11841184
}
1185+
1186+
#[cargo_test]
1187+
fn cmd_pkgid_with_embedded() {
1188+
let p = cargo_test_support::project()
1189+
.file("script.rs", ECHO_SCRIPT)
1190+
.build();
1191+
1192+
p.cargo("-Zscript pkgid --manifest-path script.rs")
1193+
.masquerade_as_nightly_cargo(&["script"])
1194+
.with_status(101)
1195+
.with_stderr(
1196+
"\
1197+
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
1198+
[ERROR] a Cargo.lock must exist for this command
1199+
",
1200+
)
1201+
.run();
1202+
}
1203+
1204+
#[cargo_test]
1205+
fn cmd_package_with_embedded() {
1206+
let p = cargo_test_support::project()
1207+
.file("script.rs", ECHO_SCRIPT)
1208+
.build();
1209+
1210+
p.cargo("-Zscript package --manifest-path script.rs")
1211+
.masquerade_as_nightly_cargo(&["script"])
1212+
.with_status(101)
1213+
.with_stderr(
1214+
"\
1215+
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
1216+
[ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
1217+
1218+
Caused by:
1219+
no targets specified in the manifest
1220+
either src/lib.rs, src/main.rs, a [lib] section, or [[bin]] section must be present
1221+
",
1222+
)
1223+
.run();
1224+
}
1225+
1226+
#[cargo_test]
1227+
fn cmd_publish_with_embedded() {
1228+
let p = cargo_test_support::project()
1229+
.file("script.rs", ECHO_SCRIPT)
1230+
.build();
1231+
1232+
p.cargo("-Zscript publish --manifest-path script.rs")
1233+
.masquerade_as_nightly_cargo(&["script"])
1234+
.with_status(101)
1235+
.with_stderr(
1236+
"\
1237+
[WARNING] `package.edition` is unspecifiead, defaulting to `2021`
1238+
[ERROR] `script` cannot be published.
1239+
`package.publish` is set to `false` or an empty list in Cargo.toml and prevents publishing.
1240+
",
1241+
)
1242+
.run();
1243+
}

0 commit comments

Comments
 (0)