2019-11-25 02:42:45 +00:00
|
|
|
//! Tests for the `cargo verify-project` command.
|
|
|
|
|
2019-09-12 17:14:29 +00:00
|
|
|
use cargo_test_support::{basic_bin_manifest, main_file, project};
|
2015-08-29 17:14:37 +00:00
|
|
|
|
|
|
|
fn verify_project_success_output() -> String {
|
|
|
|
r#"{"success":"true"}"#.into()
|
|
|
|
}
|
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn cargo_verify_project_path_to_cargo_toml_relative() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-08-29 17:14:37 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
|
|
.build();
|
2015-08-29 17:14:37 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("verify-project --manifest-path foo/Cargo.toml")
|
|
|
|
.cwd(p.root().parent().unwrap())
|
|
|
|
.with_stdout(verify_project_success_output())
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-08-29 17:14:37 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn cargo_verify_project_path_to_cargo_toml_absolute() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-08-29 17:14:37 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
|
|
.build();
|
2015-08-29 17:14:37 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("verify-project --manifest-path")
|
|
|
|
.arg(p.root().join("Cargo.toml"))
|
|
|
|
.cwd(p.root().parent().unwrap())
|
|
|
|
.with_stdout(verify_project_success_output())
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2015-08-29 17:14:37 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2016-05-25 20:55:42 +00:00
|
|
|
fn cargo_verify_project_cwd() {
|
2018-07-20 11:47:47 +00:00
|
|
|
let p = project()
|
2015-08-29 17:14:37 +00:00
|
|
|
.file("Cargo.toml", &basic_bin_manifest("foo"))
|
2017-07-22 03:12:21 +00:00
|
|
|
.file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
|
|
|
|
.build();
|
2015-08-29 17:14:37 +00:00
|
|
|
|
2018-08-28 09:20:03 +00:00
|
|
|
p.cargo("verify-project")
|
|
|
|
.with_stdout(verify_project_success_output())
|
|
|
|
.run();
|
2016-05-25 20:55:42 +00:00
|
|
|
}
|
2018-11-17 22:57:06 +00:00
|
|
|
|
2019-06-05 18:52:53 +00:00
|
|
|
#[cargo_test]
|
2018-11-17 22:57:06 +00:00
|
|
|
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"]
|
2018-11-17 22:57:06 +00:00
|
|
|
|
2020-09-27 00:59:58 +00:00
|
|
|
[package]
|
|
|
|
name = "foo"
|
|
|
|
version = "0.0.1"
|
|
|
|
"#,
|
2018-12-08 11:19:47 +00:00
|
|
|
)
|
2018-11-17 22:57:06 +00:00
|
|
|
.file("src/lib.rs", "")
|
|
|
|
.build();
|
|
|
|
|
|
|
|
p.cargo("verify-project")
|
2022-07-16 02:32:23 +00:00
|
|
|
.masquerade_as_nightly_cargo(&["test-dummy-unstable"])
|
2018-11-17 22:57:06 +00:00
|
|
|
.with_stdout(verify_project_success_output())
|
|
|
|
.run();
|
|
|
|
|
|
|
|
p.cargo("verify-project")
|
|
|
|
.with_status(1)
|
2021-06-16 16:41:38 +00:00
|
|
|
.with_json(r#"{"invalid":"failed to parse manifest at `[CWD]/Cargo.toml`"}"#)
|
2018-11-17 22:57:06 +00:00
|
|
|
.run();
|
|
|
|
}
|