Skip to content

Commit f0f912c

Browse files
committed
Add per-package-target test
1 parent de972f1 commit f0f912c

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

tests/build-std/main.rs

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,52 @@ fn cross_custom() {
170170
.run();
171171
}
172172

173+
/// like cross-custom but uses per-package-target instead
174+
#[cargo_test(build_std)]
175+
fn per_package_target() {
176+
let p = project()
177+
.file(
178+
"Cargo.toml",
179+
r#"
180+
cargo-features = ["per-package-target"]
181+
[package]
182+
name = "foo"
183+
version = "0.1.0"
184+
edition = "2018"
185+
default-target = "custom-target.json"
186+
187+
[target.custom-target.dependencies]
188+
dep = { path = "dep" }
189+
"#,
190+
)
191+
.file(
192+
"src/lib.rs",
193+
"#![no_std] pub fn f() -> u32 { dep::answer() }",
194+
)
195+
.file("dep/Cargo.toml", &basic_manifest("dep", "0.1.0"))
196+
.file("dep/src/lib.rs", "#![no_std] pub fn answer() -> u32 { 42 }")
197+
.file(
198+
"custom-target.json",
199+
r#"
200+
{
201+
"llvm-target": "x86_64-unknown-none-gnu",
202+
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
203+
"arch": "x86_64",
204+
"target-endian": "little",
205+
"target-pointer-width": "64",
206+
"target-c-int-width": "32",
207+
"os": "none",
208+
"linker-flavor": "ld.lld"
209+
}
210+
"#,
211+
)
212+
.build();
213+
214+
p.cargo("build -v")
215+
.build_std_arg("core")
216+
.run();
217+
}
218+
173219
#[cargo_test(build_std)]
174220
fn custom_test_framework() {
175221
let p = project()

0 commit comments

Comments
 (0)