blob: 7e8ceb4c67ad39e32df79165e7e46c72f67b4ba3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
//! Tests for the `cargo locate-project` command.
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();
}
|