cargo/tests/testsuite/verify_project.rs

74 lines
2 KiB
Rust
Raw Normal View History

2019-11-25 02:42:45 +00:00
//! 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()
2018-12-08 11:19:47 +00:00
.file(
"Cargo.toml",
r#"
2020-09-27 00:59:58 +00:00
cargo-features = ["test-dummy-unstable"]
2020-09-27 00:59:58 +00:00
[package]
name = "foo"
version = "0.0.1"
"#,
2018-12-08 11:19:47 +00:00
)
.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();
}