File tree Expand file tree Collapse file tree 1 file changed +113
-0
lines changed
Expand file tree Collapse file tree 1 file changed +113
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,119 @@ fn simple_cross_config() {
125125 }
126126}
127127
128+ #[ cargo_test]
129+ fn target_host_arg ( ) {
130+ if cross_compile_disabled ( ) {
131+ return ;
132+ }
133+
134+ let p = project ( )
135+ . file (
136+ "Cargo.toml" ,
137+ r#"
138+ [package]
139+ name = "foo"
140+ version = "0.0.0"
141+ edition = "2015"
142+ authors = []
143+ build = "build.rs"
144+ "# ,
145+ )
146+ . file (
147+ "build.rs" ,
148+ & format ! (
149+ r#"
150+ fn main() {{
151+ assert_eq!(std::env::var("TARGET").unwrap(), "{}");
152+ }}
153+ "# ,
154+ rustc_host( )
155+ ) ,
156+ )
157+ . file (
158+ "src/main.rs" ,
159+ & format ! (
160+ r#"
161+ use std::env;
162+ fn main() {{
163+ assert_eq!(env::consts::ARCH, "{}");
164+ }}
165+ "# ,
166+ cross_compile:: native_arch( )
167+ ) ,
168+ )
169+ . build ( ) ;
170+
171+ let target = rustc_host ( ) ;
172+ p. cargo ( "build -v --target host" ) . run ( ) ;
173+ assert ! ( p. target_bin( target, "foo" ) . is_file( ) ) ;
174+
175+ if cross_compile_can_run_on_host ( ) {
176+ p. process ( & p. target_bin ( target, "foo" ) ) . run ( ) ;
177+ }
178+ }
179+
180+ #[ cargo_test]
181+ fn target_host_config ( ) {
182+ if cross_compile_disabled ( ) {
183+ return ;
184+ }
185+
186+ let p = project ( )
187+ . file (
188+ ".cargo/config.toml" ,
189+ & format ! (
190+ r#"
191+ [build]
192+ target = "host"
193+ "# ,
194+ ) ,
195+ )
196+ . file (
197+ "Cargo.toml" ,
198+ r#"
199+ [package]
200+ name = "foo"
201+ version = "0.0.0"
202+ edition = "2015"
203+ authors = []
204+ build = "build.rs"
205+ "# ,
206+ )
207+ . file (
208+ "build.rs" ,
209+ & format ! (
210+ r#"
211+ fn main() {{
212+ assert_eq!(std::env::var("TARGET").unwrap(), "{}");
213+ }}
214+ "# ,
215+ rustc_host( )
216+ ) ,
217+ )
218+ . file (
219+ "src/main.rs" ,
220+ & format ! (
221+ r#"
222+ use std::env;
223+ fn main() {{
224+ assert_eq!(env::consts::ARCH, "{}");
225+ }}
226+ "# ,
227+ cross_compile:: native_arch( )
228+ ) ,
229+ )
230+ . build ( ) ;
231+
232+ let target = rustc_host ( ) ;
233+ p. cargo ( "build -v" ) . run ( ) ;
234+ assert ! ( p. target_bin( target, "foo" ) . is_file( ) ) ;
235+
236+ if cross_compile_can_run_on_host ( ) {
237+ p. process ( & p. target_bin ( target, "foo" ) ) . run ( ) ;
238+ }
239+ }
240+
128241#[ cargo_test]
129242fn simple_deps ( ) {
130243 if cross_compile_disabled ( ) {
You can’t perform that action at this time.
0 commit comments