Skip to content

Commit

Permalink
test: migrate testsuite verify_project to snapbox
Browse files Browse the repository at this point in the history
  • Loading branch information
henry40408 committed Jun 20, 2024
1 parent d602434 commit 1e0dca3
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions tests/testsuite/verify_project.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
//! Tests for the `cargo verify-project` command.
#![allow(deprecated)]

use cargo_test_support::{basic_bin_manifest, main_file, project};

fn verify_project_success_output() -> String {
r#"{"success":"true"}"#.into()
}
use cargo_test_support::{basic_bin_manifest, main_file, project, str};

#[cargo_test]
fn cargo_verify_project_path_to_cargo_toml_relative() {
Expand All @@ -17,7 +11,10 @@ fn cargo_verify_project_path_to_cargo_toml_relative() {

p.cargo("verify-project --manifest-path foo/Cargo.toml")
.cwd(p.root().parent().unwrap())
.with_stdout(verify_project_success_output())
.with_stdout_data(str![[r#"
{"success":"true"}
"#]])
.run();
}

Expand All @@ -31,7 +28,10 @@ fn cargo_verify_project_path_to_cargo_toml_absolute() {
p.cargo("verify-project --manifest-path")
.arg(p.root().join("Cargo.toml"))
.cwd(p.root().parent().unwrap())
.with_stdout(verify_project_success_output())
.with_stdout_data(str![[r#"
{"success":"true"}
"#]])
.run();
}

Expand All @@ -43,7 +43,10 @@ fn cargo_verify_project_cwd() {
.build();

p.cargo("verify-project")
.with_stdout(verify_project_success_output())
.with_stdout_data(str![[r#"
{"success":"true"}
"#]])
.run();
}

Expand All @@ -65,11 +68,17 @@ fn cargo_verify_project_honours_unstable_features() {

p.cargo("verify-project")
.masquerade_as_nightly_cargo(&["test-dummy-unstable"])
.with_stdout(verify_project_success_output())
.with_stdout_data(str![[r#"
{"success":"true"}
"#]])
.run();

p.cargo("verify-project")
.with_status(1)
.with_json(r#"{"invalid":"failed to parse manifest at `[CWD]/Cargo.toml`"}"#)
.with_stdout_data(str![[r#"
{"invalid":"failed to parse manifest at `[..]`"}
"#]])
.run();
}

0 comments on commit 1e0dca3

Please sign in to comment.