mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Rollup merge of #123146 - jieyouxu:use-compiletest-directives, r=clubby789
Use compiletest directives instead of manually checking TARGET / tools Changes: - Accept `ignore-wasm32-wasip1` and `needs-wasmtime` directives. - Add support for needing `wasmtime` as a runner. - Update wasm/compiler_builtin tests to use compiletest directives over manual checks.
This commit is contained in:
commit
d1630e535f
@ -691,9 +691,9 @@ pub fn line_directive<'line>(
|
||||
}
|
||||
}
|
||||
|
||||
/// This is generated by collecting directives from ui tests and then extracting their directive
|
||||
/// names. This is **not** an exhaustive list of all possible directives. Instead, this is a
|
||||
/// best-effort approximation for diagnostics.
|
||||
/// This was originally generated by collecting directives from ui tests and then extracting their
|
||||
/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is
|
||||
/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
|
||||
const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
||||
// tidy-alphabetical-start
|
||||
"assembly-output",
|
||||
@ -837,6 +837,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
||||
"needs-sanitizer-thread",
|
||||
"needs-threads",
|
||||
"needs-unwind",
|
||||
"needs-wasmtime",
|
||||
"needs-xray",
|
||||
"no-prefer-dynamic",
|
||||
"normalize-stderr-32bit",
|
||||
@ -872,6 +873,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
|
||||
"only-unix",
|
||||
"only-wasm32",
|
||||
"only-wasm32-bare",
|
||||
"only-wasm32-wasip1",
|
||||
"only-windows",
|
||||
"only-x86",
|
||||
"only-x86_64",
|
||||
|
@ -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([':', ' ']) {
|
||||
|
@ -8,6 +8,10 @@
|
||||
//! settings. Turning off optimizations and enabling debug assertions tends to produce the most
|
||||
//! dependence on core that is possible, so that is the configuration we test here.
|
||||
|
||||
// wasm and nvptx targets don't produce rlib files that object can parse.
|
||||
//@ ignore-wasm
|
||||
//@ ignore-nvptx64
|
||||
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate run_make_support;
|
||||
@ -33,10 +37,6 @@ path = "lib.rs""#;
|
||||
fn main() {
|
||||
let target_dir = tmp_dir().join("target");
|
||||
let target = std::env::var("TARGET").unwrap();
|
||||
if target.starts_with("wasm") || target.starts_with("nvptx") {
|
||||
// wasm and nvptx targets don't produce rlib files that object can parse.
|
||||
return;
|
||||
}
|
||||
|
||||
println!("Testing compiler_builtins for {}", target);
|
||||
|
||||
|
@ -1,3 +1,6 @@
|
||||
//@ only-wasm32-wasip1
|
||||
//@ needs-wasmtime
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir};
|
||||
@ -5,23 +8,10 @@ use std::path::Path;
|
||||
use std::process::Command;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
|
||||
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");
|
||||
|
@ -1,13 +1,10 @@
|
||||
//@ only-wasm32-wasip1
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
//@ only-wasm32-wasip1
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{tmp_dir, wasmparser, rustc};
|
||||
@ -5,10 +6,6 @@ use std::collections::HashMap;
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
|
||||
|
||||
verify(&tmp_dir().join("foo.wasm"));
|
||||
|
@ -1,3 +1,5 @@
|
||||
//@ only-wasm32-wasip1
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{tmp_dir, wasmparser, rustc};
|
||||
@ -6,10 +8,6 @@ use std::path::Path;
|
||||
use wasmparser::ExternalKind::*;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test(&[]);
|
||||
test(&["-O"]);
|
||||
test(&["-Clto"]);
|
||||
|
@ -1,3 +1,5 @@
|
||||
//@ only-wasm32-wasip1
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{tmp_dir, wasmparser, rustc};
|
||||
@ -5,10 +7,6 @@ use std::collections::HashMap;
|
||||
use wasmparser::TypeRef::Func;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
rustc()
|
||||
.input("bar.rs")
|
||||
|
@ -1,3 +1,4 @@
|
||||
//@ only-wasm32-wasip1
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate run_make_support;
|
||||
@ -5,10 +6,6 @@ extern crate run_make_support;
|
||||
use run_make_support::{rustc, tmp_dir};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test("a");
|
||||
test("b");
|
||||
test("c");
|
||||
|
@ -1,13 +1,11 @@
|
||||
//@ only-wasm32-wasip1
|
||||
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc()
|
||||
.input("main.rs")
|
||||
.target("wasm32-wasip1")
|
||||
|
@ -1,3 +1,4 @@
|
||||
//@ only-wasm32-wasip1
|
||||
#![deny(warnings)]
|
||||
|
||||
extern crate run_make_support;
|
||||
@ -5,10 +6,6 @@ extern crate run_make_support;
|
||||
use run_make_support::{rustc, tmp_dir};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
|
||||
|
||||
let bytes = std::fs::read(&tmp_dir().join("foo.wasm")).unwrap();
|
||||
|
@ -1,13 +1,10 @@
|
||||
//@ only-wasm32-wasip1
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use std::collections::{HashMap, HashSet};
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
test_file("foo.rs", &[("a", &["foo"]), ("b", &["foo"])]);
|
||||
test_file("bar.rs", &[("m1", &["f", "g"]), ("m2", &["f"])]);
|
||||
test_file("baz.rs", &[("sqlite", &["allocate", "deallocate"])]);
|
||||
|
@ -1,13 +1,10 @@
|
||||
//@ only-wasm32-wasip1
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
verify_symbols(&tmp_dir().join("foo.wasm"));
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
|
||||
|
@ -1,13 +1,10 @@
|
||||
//@ only-wasm32-wasip1
|
||||
extern crate run_make_support;
|
||||
|
||||
use run_make_support::{rustc, tmp_dir, wasmparser};
|
||||
use std::path::Path;
|
||||
|
||||
fn main() {
|
||||
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
|
||||
return;
|
||||
}
|
||||
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").run();
|
||||
verify_symbols(&tmp_dir().join("foo.wasm"));
|
||||
rustc().input("foo.rs").target("wasm32-wasip1").arg("-Clto").run();
|
||||
|
Loading…
Reference in New Issue
Block a user