From 98ed8abe6da603f9263c6fd2c244749088f75ccf Mon Sep 17 00:00:00 2001 From: Ed Page Date: Mon, 19 Jun 2023 14:24:46 -0500 Subject: [PATCH] test(embedded): Verify existing behavior on basic commands --- tests/testsuite/script.rs | 198 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 198 insertions(+) diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index 638677bc4..3506bc603 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -10,6 +10,9 @@ fn main() { println!("bin: {bin}"); println!("args: {args:?}"); } + +#[test] +fn test () {} "#; #[cfg(unix)] @@ -621,3 +624,198 @@ args: [] assert!(!local_lockfile_path.exists()); } + +#[cargo_test] +fn cmd_check_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript check --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_build_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript build --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_test_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript test --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_clean_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + // Ensure there is something to clean + p.cargo("-Zscript script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .run(); + + p.cargo("-Zscript clean --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_generate_lockfile_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript generate-lockfile --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_metadata_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript metadata --manifest-path script.rs --format-version=1") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_read_manifest_with_embedded() { + let script = ECHO_SCRIPT; + let p = cargo_test_support::project() + .file("script.rs", script) + .build(); + + p.cargo("-Zscript read-manifest --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_run_with_embedded() { + let p = cargo_test_support::project() + .file("script.rs", ECHO_SCRIPT) + .build(); + + p.cargo("-Zscript run --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_tree_with_embedded() { + let p = cargo_test_support::project() + .file("script.rs", ECHO_SCRIPT) + .build(); + + p.cargo("-Zscript tree --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_update_with_embedded() { + let p = cargo_test_support::project() + .file("script.rs", ECHO_SCRIPT) + .build(); + + p.cargo("-Zscript update --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(101) + .with_stderr( + "\ +[ERROR] the manifest-path must be a path to a Cargo.toml file +", + ) + .run(); +} + +#[cargo_test] +fn cmd_verify_project_with_embedded() { + let p = cargo_test_support::project() + .file("script.rs", ECHO_SCRIPT) + .build(); + + p.cargo("-Zscript verify-project --manifest-path script.rs") + .masquerade_as_nightly_cargo(&["script"]) + .with_status(1) + .with_stdout(r#"{"invalid":"the manifest-path must be a path to a Cargo.toml file"}"#) + .run(); +}