11//! Tests for --build-plan feature.
22
3- #![ allow( deprecated) ]
4-
3+ use cargo_test_support:: prelude:: * ;
54use cargo_test_support:: registry:: Package ;
6- use cargo_test_support:: { basic_bin_manifest, basic_manifest, main_file, project} ;
5+ use cargo_test_support:: { basic_bin_manifest, basic_manifest, main_file, project, str } ;
76
87#[ cargo_test]
98fn cargo_build_plan_simple ( ) {
@@ -14,30 +13,33 @@ fn cargo_build_plan_simple() {
1413
1514 p. cargo ( "build --build-plan -Zunstable-options" )
1615 . masquerade_as_nightly_cargo ( & [ "build-plan" ] )
17- . with_json (
18- r#"
19- {
20- "inputs": [
21- "[..]/foo/Cargo.toml"
22- ],
23- "invocations": [
24- {
25- "args": "{...}",
26- "cwd": "[..]/cit/[..]/foo",
27- "deps": [],
28- "env": "{...}",
29- "kind": null,
30- "links": "{...}",
31- "outputs": "{...}",
32- "package_name": "foo",
33- "package_version": "0.5.0",
34- "program": "rustc",
35- "target_kind": ["bin"],
36- "compile_mode": "build"
37- }
38- ]
39- }
40- "# ,
16+ . with_stdout_data (
17+ str![ [ r#"
18+ {
19+ "inputs": [
20+ "[ROOT]/foo/Cargo.toml"
21+ ],
22+ "invocations": [
23+ {
24+ "args": "{...}",
25+ "compile_mode": "build",
26+ "cwd": "[ROOT]/foo",
27+ "deps": [],
28+ "env": "{...}",
29+ "kind": null,
30+ "links": "{...}",
31+ "outputs": "{...}",
32+ "package_name": "foo",
33+ "package_version": "0.5.0",
34+ "program": "rustc",
35+ "target_kind": [
36+ "bin"
37+ ]
38+ }
39+ ]
40+ }
41+ "# ] ]
42+ . json ( ) ,
4143 )
4244 . run ( ) ;
4345 assert ! ( !p. bin( "foo" ) . is_file( ) ) ;
@@ -73,51 +75,58 @@ fn cargo_build_plan_single_dep() {
7375 . build ( ) ;
7476 p. cargo ( "build --build-plan -Zunstable-options" )
7577 . masquerade_as_nightly_cargo ( & [ "build-plan" ] )
76- . with_json (
77- r#"
78- {
79- "inputs": [
80- "[..]/foo/Cargo.toml",
81- "[..]/foo/bar/Cargo.toml"
82- ],
83- "invocations": [
84- {
85- "args": "{...}",
86- "cwd": "[..]/cit/[..]/foo",
87- "deps": [],
88- "env": "{...}",
89- "kind": null,
90- "links": "{...}",
91- "outputs": [
92- "[..]/foo/target/debug/deps/libbar-[..].rlib",
93- "[..]/foo/target/debug/deps/libbar-[..].rmeta"
94- ],
95- "package_name": "bar",
96- "package_version": "0.0.1",
97- "program": "rustc",
98- "target_kind": ["lib"],
99- "compile_mode": "build"
100- },
101- {
102- "args": "{...}",
103- "cwd": "[..]/cit/[..]/foo",
104- "deps": [0],
105- "env": "{...}",
106- "kind": null,
107- "links": "{...}",
108- "outputs": [
109- "[..]/foo/target/debug/deps/libfoo-[..].rlib",
110- "[..]/foo/target/debug/deps/libfoo-[..].rmeta"
111- ],
112- "package_name": "foo",
113- "package_version": "0.5.0",
114- "program": "rustc",
115- "target_kind": ["lib"],
116- "compile_mode": "build"
117- }
118- ]
119- }
120- "# ,
78+ . with_stdout_data (
79+ str![ [ r#"
80+ {
81+ "inputs": [
82+ "[ROOT]/foo/Cargo.toml",
83+ "[ROOT]/foo/bar/Cargo.toml"
84+ ],
85+ "invocations": [
86+ {
87+ "args": "{...}",
88+ "compile_mode": "build",
89+ "cwd": "[ROOT]/foo",
90+ "deps": [],
91+ "env": "{...}",
92+ "kind": null,
93+ "links": {},
94+ "outputs": [
95+ "[ROOT]/foo/target/debug/deps/libbar-[HASH].rlib",
96+ "[ROOT]/foo/target/debug/deps/libbar-[HASH].rmeta"
97+ ],
98+ "package_name": "bar",
99+ "package_version": "0.0.1",
100+ "program": "rustc",
101+ "target_kind": [
102+ "lib"
103+ ]
104+ },
105+ {
106+ "args": "{...}",
107+ "compile_mode": "build",
108+ "cwd": "[ROOT]/foo",
109+ "deps": [
110+ 0
111+ ],
112+ "env": "{...}",
113+ "kind": null,
114+ "links": "{...}",
115+ "outputs": [
116+ "[ROOT]/foo/target/debug/deps/libfoo-[HASH].rlib",
117+ "[ROOT]/foo/target/debug/deps/libfoo-[HASH].rmeta"
118+ ],
119+ "package_name": "foo",
120+ "package_version": "0.5.0",
121+ "program": "rustc",
122+ "target_kind": [
123+ "lib"
124+ ]
125+ }
126+ ]
127+ }
128+ "# ] ]
129+ . json ( ) ,
121130 )
122131 . run ( ) ;
123132}
@@ -142,58 +151,69 @@ fn cargo_build_plan_build_script() {
142151
143152 p. cargo ( "build --build-plan -Zunstable-options" )
144153 . masquerade_as_nightly_cargo ( & [ "build-plan" ] )
145- . with_json (
146- r#"
147- {
148- "inputs": [
149- "[..]/foo/Cargo.toml"
150- ],
151- "invocations": [
152- {
153- "args": "{...}",
154- "cwd": "[..]/cit/[..]/foo",
155- "deps": [],
156- "env": "{...}",
157- "kind": null,
158- "links": "{...}",
159- "outputs": "{...}",
160- "package_name": "foo",
161- "package_version": "0.5.0",
162- "program": "rustc",
163- "target_kind": ["custom-build"],
164- "compile_mode": "build"
165- },
166- {
167- "args": "{...}",
168- "cwd": "[..]/cit/[..]/foo",
169- "deps": [0],
170- "env": "{...}",
171- "kind": null,
172- "links": "{...}",
173- "outputs": [],
174- "package_name": "foo",
175- "package_version": "0.5.0",
176- "program": "[..]/build-script-build",
177- "target_kind": ["custom-build"],
178- "compile_mode": "run-custom-build"
179- },
180- {
181- "args": "{...}",
182- "cwd": "[..]/cit/[..]/foo",
183- "deps": [1],
184- "env": "{...}",
185- "kind": null,
186- "links": "{...}",
187- "outputs": "{...}",
188- "package_name": "foo",
189- "package_version": "0.5.0",
190- "program": "rustc",
191- "target_kind": ["bin"],
192- "compile_mode": "build"
193- }
194- ]
195- }
196- "# ,
154+ . with_stdout_data (
155+ str![ [ r#"
156+ {
157+ "inputs": [
158+ "[ROOT]/foo/Cargo.toml"
159+ ],
160+ "invocations": [
161+ {
162+ "args": "{...}",
163+ "compile_mode": "build",
164+ "cwd": "[ROOT]/foo",
165+ "deps": [],
166+ "env": "{...}",
167+ "kind": null,
168+ "links": "{...}",
169+ "outputs": "{...}",
170+ "package_name": "foo",
171+ "package_version": "0.5.0",
172+ "program": "rustc",
173+ "target_kind": [
174+ "custom-build"
175+ ]
176+ },
177+ {
178+ "args": "{...}",
179+ "compile_mode": "run-custom-build",
180+ "cwd": "[ROOT]/foo",
181+ "deps": [
182+ 0
183+ ],
184+ "env": "{...}",
185+ "kind": null,
186+ "links": {},
187+ "outputs": [],
188+ "package_name": "foo",
189+ "package_version": "0.5.0",
190+ "program": "[ROOT]/foo/target/debug/build/foo-[HASH]/build-script-build",
191+ "target_kind": [
192+ "custom-build"
193+ ]
194+ },
195+ {
196+ "args": "{...}",
197+ "compile_mode": "build",
198+ "cwd": "[ROOT]/foo",
199+ "deps": [
200+ 1
201+ ],
202+ "env": "{...}",
203+ "kind": null,
204+ "links": "{...}",
205+ "outputs": "{...}",
206+ "package_name": "foo",
207+ "package_version": "0.5.0",
208+ "program": "rustc",
209+ "target_kind": [
210+ "bin"
211+ ]
212+ }
213+ ]
214+ }
215+ "# ] ]
216+ . json ( ) ,
197217 )
198218 . run ( ) ;
199219}
0 commit comments