cargo/tests/testsuite/verify_project.rs
Ed Page 5b9799c6f4 refactor: Migrate from extern crate to test-support prelude
We now include the prelude in so many places, this simplifies how we can
present how `cargo-test-support` works.

Yes, this included some `use` clean ups but its already painful enough
walking through every test file, I didn't want to do it twice.
2024-07-12 15:57:00 -05:00

86 lines
2.0 KiB
Rust

//! Tests for the `cargo verify-project` command.
use cargo_test_support::prelude::*;
use cargo_test_support::{basic_bin_manifest, main_file, project, str};
#[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_data(str![[r#"
{"success":"true"}
"#]])
.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_data(str![[r#"
{"success":"true"}
"#]])
.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_data(str![[r#"
{"success":"true"}
"#]])
.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_data(str![[r#"
{"success":"true"}
"#]])
.run();
p.cargo("verify-project")
.with_status(1)
.with_stdout_data(str![[r#"
{"invalid":"failed to parse manifest at `[..]`"}
"#]])
.run();
}