Skip to content

Commit 02c0f7e

Browse files
committed
test: migrate locate_project to snapbox
1 parent c3327ed commit 02c0f7e

File tree

1 file changed

+60
-13
lines changed

1 file changed

+60
-13
lines changed

tests/testsuite/locate_project.rs

Lines changed: 60 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,22 @@
11
//! Tests for the `cargo locate-project` command.
22
3-
#![allow(deprecated)]
4-
3+
use cargo_test_support::prelude::*;
54
use cargo_test_support::project;
5+
use cargo_test_support::str;
66

77
#[cargo_test]
88
fn simple() {
99
let p = project().build();
1010

1111
p.cargo("locate-project")
12-
.with_json(r#"{"root": "[ROOT]/foo/Cargo.toml"}"#)
12+
.with_stdout_data(
13+
str![[r#"
14+
{
15+
"root": "[ROOT]/foo/Cargo.toml"
16+
}
17+
"#]]
18+
.json(),
19+
)
1320
.run();
1421
}
1522

@@ -18,15 +25,28 @@ fn message_format() {
1825
let p = project().build();
1926

2027
p.cargo("locate-project --message-format plain")
21-
.with_stdout("[ROOT]/foo/Cargo.toml")
28+
.with_stdout_data(str![[r#"
29+
[ROOT]/foo/Cargo.toml
30+
31+
"#]])
2232
.run();
2333

2434
p.cargo("locate-project --message-format json")
25-
.with_json(r#"{"root": "[ROOT]/foo/Cargo.toml"}"#)
35+
.with_stdout_data(
36+
str![[r#"
37+
{
38+
"root": "[ROOT]/foo/Cargo.toml"
39+
}
40+
"#]]
41+
.json(),
42+
)
2643
.run();
2744

2845
p.cargo("locate-project --message-format cryptic")
29-
.with_stderr("error: invalid message format specifier: `cryptic`")
46+
.with_stderr_data(str![[r#"
47+
[ERROR] invalid message format specifier: `cryptic`
48+
49+
"#]])
3050
.with_status(101)
3151
.run();
3252
}
@@ -57,22 +77,49 @@ fn workspace() {
5777
.file("inner/src/lib.rs", "")
5878
.build();
5979

60-
let outer_manifest = r#"{"root": "[ROOT]/foo/Cargo.toml"}"#;
61-
let inner_manifest = r#"{"root": "[ROOT]/foo/inner/Cargo.toml"}"#;
62-
63-
p.cargo("locate-project").with_json(outer_manifest).run();
80+
p.cargo("locate-project")
81+
.with_stdout_data(
82+
str![[r#"
83+
{
84+
"root": "[ROOT]/foo/Cargo.toml"
85+
}
86+
"#]]
87+
.json(),
88+
)
89+
.run();
6490

6591
p.cargo("locate-project")
6692
.cwd("inner")
67-
.with_json(inner_manifest)
93+
.with_stdout_data(
94+
str![[r#"
95+
{
96+
"root": "[ROOT]/foo/inner/Cargo.toml"
97+
}
98+
"#]]
99+
.json(),
100+
)
68101
.run();
69102

70103
p.cargo("locate-project --workspace")
71-
.with_json(outer_manifest)
104+
.with_stdout_data(
105+
str![[r#"
106+
{
107+
"root": "[ROOT]/foo/Cargo.toml"
108+
}
109+
"#]]
110+
.json(),
111+
)
72112
.run();
73113

74114
p.cargo("locate-project --workspace")
75115
.cwd("inner")
76-
.with_json(outer_manifest)
116+
.with_stdout_data(
117+
str![[r#"
118+
{
119+
"root": "[ROOT]/foo/Cargo.toml"
120+
}
121+
"#]]
122+
.json(),
123+
)
77124
.run();
78125
}

0 commit comments

Comments
 (0)