Convert wasmtime check into a compiletest needs directive

This commit is contained in:
许杰友 Jieyou Xu (Joe) 2024-03-27 22:02:45 +00:00
parent 08853804d0
commit 12e999274d
No known key found for this signature in database
GPG Key ID: 95DDEBD74A1DC2C0
3 changed files with 7 additions and 9 deletions

View File

@ -837,6 +837,7 @@ pub fn line_directive<'line>(
"needs-sanitizer-thread",
"needs-threads",
"needs-unwind",
"needs-wasmtime",
"needs-xray",
"no-prefer-dynamic",
"normalize-stderr-32bit",

View File

@ -149,6 +149,11 @@ pub(super) fn handle_needs(
condition: config.target_cfg().relocation_model == "pic",
ignore_reason: "ignored on targets without PIC relocation model",
},
Need {
name: "needs-wasmtime",
condition: config.runner.as_ref().is_some_and(|r| r.contains("wasmtime")),
ignore_reason: "ignored when wasmtime runner is not available",
},
];
let (name, comment) = match ln.split_once([':', ' ']) {

View File

@ -1,4 +1,5 @@
//@ only-wasm32-wasip1
//@ needs-wasmtime
extern crate run_make_support;
@ -11,15 +12,6 @@ fn main() {
let file = tmp_dir().join("foo.wasm");
let has_wasmtime = match Command::new("wasmtime").arg("--version").output() {
Ok(s) => s.status.success(),
_ => false,
};
if !has_wasmtime {
println!("skipping test, wasmtime isn't available");
return;
}
run(&file, "return_two_i32", "1\n2\n");
run(&file, "return_two_i64", "3\n4\n");
run(&file, "return_two_f32", "5\n6\n");