Skip to content

Commit 6b4fd44

Browse files
committed
Add a test for -Zbuild-std with custom test frameworks
1 parent 18a8973 commit 6b4fd44

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/standard_lib.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ fn std_lib() {
3737
hashbrown();
3838
libc();
3939
test();
40+
custom_test_framework();
4041
target_proc_macro();
4142
bench();
4243
doc();
@@ -186,6 +187,47 @@ fn test() {
186187
.run();
187188
}
188189

190+
fn custom_test_framework() {
191+
let p = project()
192+
.file(
193+
"src/lib.rs",
194+
r#"
195+
#![no_std]
196+
#![cfg_attr(test, no_main)]
197+
#![feature(custom_test_frameworks)]
198+
#![test_runner(crate::test_runner)]
199+
200+
pub fn test_runner(_tests: &[&dyn Fn()]) {}
201+
202+
#[panic_handler]
203+
fn panic(_info: &core::panic::PanicInfo) -> ! {
204+
loop {}
205+
}
206+
"#,
207+
)
208+
.file(
209+
"target.json",
210+
r#"
211+
{
212+
"llvm-target": "x86_64-unknown-none-gnu",
213+
"data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128",
214+
"arch": "x86_64",
215+
"target-endian": "little",
216+
"target-pointer-width": "64",
217+
"target-c-int-width": "32",
218+
"os": "none",
219+
"linker-flavor": "ld.lld",
220+
"linker": "rust-lld",
221+
"executables": true,
222+
"panic-strategy": "abort"
223+
}
224+
"#,
225+
)
226+
.build();
227+
228+
cargo_build_std(&p, "test --target target.json --no-run -v", "core").run();
229+
}
230+
189231
fn target_proc_macro() {
190232
let p = project()
191233
.file(

0 commit comments

Comments
 (0)