1
1
//! Tests for the `cargo locate-project` command.
2
2
3
- #![ allow( deprecated) ]
4
-
3
+ use cargo_test_support:: prelude:: * ;
5
4
use cargo_test_support:: project;
5
+ use cargo_test_support:: str;
6
6
7
7
#[ cargo_test]
8
8
fn simple ( ) {
9
9
let p = project ( ) . build ( ) ;
10
10
11
11
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
+ )
13
20
. run ( ) ;
14
21
}
15
22
@@ -18,15 +25,28 @@ fn message_format() {
18
25
let p = project ( ) . build ( ) ;
19
26
20
27
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
+ "# ] ] )
22
32
. run ( ) ;
23
33
24
34
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
+ )
26
43
. run ( ) ;
27
44
28
45
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
+ "# ] ] )
30
50
. with_status ( 101 )
31
51
. run ( ) ;
32
52
}
@@ -57,22 +77,49 @@ fn workspace() {
57
77
. file ( "inner/src/lib.rs" , "" )
58
78
. build ( ) ;
59
79
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 ( ) ;
64
90
65
91
p. cargo ( "locate-project" )
66
92
. 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
+ )
68
101
. run ( ) ;
69
102
70
103
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
+ )
72
112
. run ( ) ;
73
113
74
114
p. cargo ( "locate-project --workspace" )
75
115
. 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
+ )
77
124
. run ( ) ;
78
125
}
0 commit comments