summaryrefslogtreecommitdiffstats
path: root/tests/testsuite/verify_project.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:47:55 +0000
commit2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4 (patch)
tree033cc839730fda84ff08db877037977be94e5e3a /tests/testsuite/verify_project.rs
parentInitial commit. (diff)
downloadcargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.tar.xz
cargo-2aadc03ef15cb5ca5cc2af8a7c08e070742f0ac4.zip
Adding upstream version 0.70.1+ds1.upstream/0.70.1+ds1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/testsuite/verify_project.rs')
-rw-r--r--tests/testsuite/verify_project.rs73
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/testsuite/verify_project.rs b/tests/testsuite/verify_project.rs
new file mode 100644
index 0000000..216808f
--- /dev/null
+++ b/tests/testsuite/verify_project.rs
@@ -0,0 +1,73 @@
+//! Tests for the `cargo verify-project` command.
+
+use cargo_test_support::{basic_bin_manifest, main_file, project};
+
+fn verify_project_success_output() -> String {
+ r#"{"success":"true"}"#.into()
+}
+
+#[cargo_test]
+fn cargo_verify_project_path_to_cargo_toml_relative() {
+ let p = project()
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
+
+ p.cargo("verify-project --manifest-path foo/Cargo.toml")
+ .cwd(p.root().parent().unwrap())
+ .with_stdout(verify_project_success_output())
+ .run();
+}
+
+#[cargo_test]
+fn cargo_verify_project_path_to_cargo_toml_absolute() {
+ let p = project()
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
+
+ p.cargo("verify-project --manifest-path")
+ .arg(p.root().join("Cargo.toml"))
+ .cwd(p.root().parent().unwrap())
+ .with_stdout(verify_project_success_output())
+ .run();
+}
+
+#[cargo_test]
+fn cargo_verify_project_cwd() {
+ let p = project()
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
+
+ p.cargo("verify-project")
+ .with_stdout(verify_project_success_output())
+ .run();
+}
+
+#[cargo_test]
+fn cargo_verify_project_honours_unstable_features() {
+ let p = project()
+ .file(
+ "Cargo.toml",
+ r#"
+ cargo-features = ["test-dummy-unstable"]
+
+ [package]
+ name = "foo"
+ version = "0.0.1"
+ "#,
+ )
+ .file("src/lib.rs", "")
+ .build();
+
+ p.cargo("verify-project")
+ .masquerade_as_nightly_cargo(&["test-dummy-unstable"])
+ .with_stdout(verify_project_success_output())
+ .run();
+
+ p.cargo("verify-project")
+ .with_status(1)
+ .with_json(r#"{"invalid":"failed to parse manifest at `[CWD]/Cargo.toml`"}"#)
+ .run();
+}