Skip to content

Commit 2a7e5c0

Browse files
committed
test(script): Show existing non-existent behavior
1 parent c377c2a commit 2a7e5c0

File tree

1 file changed

+86
-2
lines changed

1 file changed

+86
-2
lines changed

tests/testsuite/script.rs

Lines changed: 86 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,14 +600,14 @@ fn script_like_dir() {
600600
.with_status(101)
601601
.with_stderr(
602602
"\
603-
error: manifest path `foo.rs` is a directory but expected a file
603+
[ERROR] manifest path `foo.rs` is a directory but expected a file
604604
",
605605
)
606606
.run();
607607
}
608608

609609
#[cargo_test]
610-
fn missing_script_rs() {
610+
fn non_existent_rs() {
611611
let p = cargo_test_support::project().build();
612612

613613
p.cargo("-Zscript -v foo.rs")
@@ -621,6 +621,90 @@ fn missing_script_rs() {
621621
.run();
622622
}
623623

624+
#[cargo_test]
625+
fn non_existent_rs_stable() {
626+
let p = cargo_test_support::project().build();
627+
628+
p.cargo("-v foo.rs")
629+
.masquerade_as_nightly_cargo(&["script"])
630+
.with_status(101)
631+
.with_stdout("")
632+
.with_stderr(
633+
"\
634+
[ERROR] running `foo.rs` requires `-Zscript`
635+
",
636+
)
637+
.run();
638+
}
639+
640+
#[cargo_test]
641+
fn did_you_mean_file() {
642+
let p = cargo_test_support::project()
643+
.file("food.rs", ECHO_SCRIPT)
644+
.build();
645+
646+
p.cargo("-Zscript -v foo.rs")
647+
.masquerade_as_nightly_cargo(&["script"])
648+
.with_status(101)
649+
.with_stdout("")
650+
.with_stderr(
651+
"\
652+
[ERROR] manifest path `foo.rs` does not exist
653+
",
654+
)
655+
.run();
656+
}
657+
658+
#[cargo_test]
659+
fn did_you_mean_file_stable() {
660+
let p = cargo_test_support::project()
661+
.file("food.rs", ECHO_SCRIPT)
662+
.build();
663+
664+
p.cargo("-v foo.rs")
665+
.masquerade_as_nightly_cargo(&["script"])
666+
.with_status(101)
667+
.with_stdout("")
668+
.with_stderr(
669+
"\
670+
[ERROR] running `foo.rs` requires `-Zscript`
671+
",
672+
)
673+
.run();
674+
}
675+
676+
#[cargo_test]
677+
fn did_you_mean_command() {
678+
let p = cargo_test_support::project().build();
679+
680+
p.cargo("-Zscript -v build--manifest-path=./Cargo.toml")
681+
.masquerade_as_nightly_cargo(&["script"])
682+
.with_status(101)
683+
.with_stdout("")
684+
.with_stderr(
685+
"\
686+
[ERROR] manifest path `build--manifest-path=./Cargo.toml` does not exist
687+
",
688+
)
689+
.run();
690+
}
691+
692+
#[cargo_test]
693+
fn did_you_mean_command_stable() {
694+
let p = cargo_test_support::project().build();
695+
696+
p.cargo("-v build--manifest-path=./Cargo.toml")
697+
.masquerade_as_nightly_cargo(&["script"])
698+
.with_status(101)
699+
.with_stdout("")
700+
.with_stderr(
701+
"\
702+
[ERROR] running `build--manifest-path=./Cargo.toml` requires `-Zscript`
703+
",
704+
)
705+
.run();
706+
}
707+
624708
#[cargo_test]
625709
fn test_name_same_as_dependency() {
626710
Package::new("script", "1.0.0").publish();

0 commit comments

Comments
 (0)