@@ -92,9 +92,7 @@ fn basic() {
92
92
p. cargo ( "test" ) . masquerade_as_nightly_cargo ( ) . run ( ) ;
93
93
94
94
// Check for hack that removes dylibs.
95
- let deps_dir = Path :: new ( "target" )
96
- . join ( "debug" )
97
- . join ( "deps" ) ;
95
+ let deps_dir = Path :: new ( "target" ) . join ( "debug" ) . join ( "deps" ) ;
98
96
assert ! ( p. glob( deps_dir. join( "*.rlib" ) ) . count( ) > 0 ) ;
99
97
assert_eq ! ( p. glob( deps_dir. join( "*.dylib" ) ) . count( ) , 0 ) ;
100
98
}
@@ -212,3 +210,59 @@ fn custom_test_framework() {
212
210
. env ( "PATH" , new_path)
213
211
. run ( ) ;
214
212
}
213
+
214
+ #[ cargo_test( build_std) ]
215
+ fn forced_custom_target ( ) {
216
+ // Checks how per-package-targets interct with build-std.
217
+
218
+ let p = project ( )
219
+ . file (
220
+ "src/main.rs" ,
221
+ "
222
+ #![no_std]
223
+ #![no_main]
224
+
225
+ #[panic_handler]
226
+ fn panic(_info: &core::panic::PanicInfo) -> ! {
227
+ loop {}
228
+ }
229
+
230
+ pub fn foo() -> u8 { 42 }
231
+ " ,
232
+ )
233
+ . file (
234
+ "Cargo.toml" ,
235
+ r#"
236
+ cargo-features = ["build-std", "per-package-target"]
237
+ [package]
238
+ name = "foo"
239
+ version = "0.1.0"
240
+ edition = "2018"
241
+ build-std = ["core"]
242
+ forced-target = "custom-target.json"
243
+ "# ,
244
+ )
245
+ . file (
246
+ "custom-target.json" ,
247
+ r#"
248
+ {
249
+ "llvm-target": "x86_64-unknown-none-gnu",
250
+ "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
251
+ "arch": "x86_64",
252
+ "target-endian": "little",
253
+ "target-pointer-width": "64",
254
+ "target-c-int-width": "32",
255
+ "os": "none",
256
+ "linker-flavor": "ld.lld",
257
+ "linker": "rust-lld",
258
+ "executables": true,
259
+ "panic-strategy": "abort"
260
+ }
261
+ "# ,
262
+ )
263
+ . build ( ) ;
264
+
265
+ p. cargo ( "build" ) . masquerade_as_nightly_cargo ( ) . run ( ) ;
266
+
267
+ assert ! ( p. target_bin( "custom-target" , "foo" ) . exists( ) ) ;
268
+ }
0 commit comments