cargo/tests/testsuite/locate_project.rs
Ed Page dc5ac62cab fix(test): Deprecate non-snapbox assertions
While this is noisy and hides other deprecations, I figured deprecations would
make it easier for people to discover what tasks remain and allow us to
divide and conquer this work rather than doing a heroic PR.
In theory, this will be short lived and we'll go back to seeing
deprecations in our tests.
2024-06-10 10:20:52 -05:00

79 lines
1.8 KiB
Rust

//! Tests for the `cargo locate-project` command.
#![allow(deprecated)]
use cargo_test_support::project;
#[cargo_test]
fn simple() {
let p = project().build();
p.cargo("locate-project")
.with_json(r#"{"root": "[ROOT]/foo/Cargo.toml"}"#)
.run();
}
#[cargo_test]
fn message_format() {
let p = project().build();
p.cargo("locate-project --message-format plain")
.with_stdout("[ROOT]/foo/Cargo.toml")
.run();
p.cargo("locate-project --message-format json")
.with_json(r#"{"root": "[ROOT]/foo/Cargo.toml"}"#)
.run();
p.cargo("locate-project --message-format cryptic")
.with_stderr("error: invalid message format specifier: `cryptic`")
.with_status(101)
.run();
}
#[cargo_test]
fn workspace() {
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "outer"
version = "0.0.0"
[workspace]
members = ["inner"]
"#,
)
.file("src/main.rs", "fn main() {}")
.file(
"inner/Cargo.toml",
r#"
[package]
name = "inner"
version = "0.0.0"
"#,
)
.file("inner/src/lib.rs", "")
.build();
let outer_manifest = r#"{"root": "[ROOT]/foo/Cargo.toml"}"#;
let inner_manifest = r#"{"root": "[ROOT]/foo/inner/Cargo.toml"}"#;
p.cargo("locate-project").with_json(outer_manifest).run();
p.cargo("locate-project")
.cwd("inner")
.with_json(inner_manifest)
.run();
p.cargo("locate-project --workspace")
.with_json(outer_manifest)
.run();
p.cargo("locate-project --workspace")
.cwd("inner")
.with_json(outer_manifest)
.run();
}