Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d1630e5

Browse files
Rollup merge of rust-lang#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.
2 parents 69cfe80 + 9762d66 commit d1630e5

File tree

14 files changed

+30
-60
lines changed

14 files changed

+30
-60
lines changed

‎src/tools/compiletest/src/header.rs‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,9 @@ pub fn line_directive<'line>(
691691
}
692692
}
693693

694-
/// This is generated by collecting directives from ui tests and then extracting their directive
695-
/// names. This is **not** an exhaustive list of all possible directives. Instead, this is a
696-
/// best-effort approximation for diagnostics.
694+
/// This was originally generated by collecting directives from ui tests and then extracting their
695+
/// directive names. This is **not** an exhaustive list of all possible directives. Instead, this is
696+
/// a best-effort approximation for diagnostics. Add new headers to this list when needed.
697697
const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
698698
// tidy-alphabetical-start
699699
"assembly-output",
@@ -837,6 +837,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
837837
"needs-sanitizer-thread",
838838
"needs-threads",
839839
"needs-unwind",
840+
"needs-wasmtime",
840841
"needs-xray",
841842
"no-prefer-dynamic",
842843
"normalize-stderr-32bit",
@@ -872,6 +873,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
872873
"only-unix",
873874
"only-wasm32",
874875
"only-wasm32-bare",
876+
"only-wasm32-wasip1",
875877
"only-windows",
876878
"only-x86",
877879
"only-x86_64",

‎src/tools/compiletest/src/header/needs.rs‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ pub(super) fn handle_needs(
149149
condition: config.target_cfg().relocation_model == "pic",
150150
ignore_reason: "ignored on targets without PIC relocation model",
151151
},
152+
Need {
153+
name: "needs-wasmtime",
154+
condition: config.runner.as_ref().is_some_and(|r| r.contains("wasmtime")),
155+
ignore_reason: "ignored when wasmtime runner is not available",
156+
},
152157
];
153158

154159
let (name, comment) = match ln.split_once([':', ' ']) {

‎tests/run-make/compiler-builtins/rmake.rs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@
88
//! settings. Turning off optimizations and enabling debug assertions tends to produce the most
99
//! dependence on core that is possible, so that is the configuration we test here.
1010
11+
// wasm and nvptx targets don't produce rlib files that object can parse.
12+
//@ ignore-wasm
13+
//@ ignore-nvptx64
14+
1115
#![deny(warnings)]
1216

1317
extern crate run_make_support;
@@ -33,10 +37,6 @@ path = "lib.rs""#;
3337
fn main() {
3438
let target_dir = tmp_dir().join("target");
3539
let target = std::env::var("TARGET").unwrap();
36-
if target.starts_with("wasm") || target.starts_with("nvptx") {
37-
// wasm and nvptx targets don't produce rlib files that object can parse.
38-
return;
39-
}
4040

4141
println!("Testing compiler_builtins for {}", target);
4242

‎tests/run-make/wasm-abi/rmake.rs‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,17 @@
1+
//@ only-wasm32-wasip1
2+
//@ needs-wasmtime
3+
14
extern crate run_make_support;
25

36
use run_make_support::{rustc, tmp_dir};
47
use std::path::Path;
58
use std::process::Command;
69

710
fn main() {
8-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
9-
return;
10-
}
11-
1211
rustc().input("foo.rs").target("wasm32-wasip1").run();
1312

1413
let file = tmp_dir().join("foo.wasm");
1514

16-
let has_wasmtime = match Command::new("wasmtime").arg("--version").output() {
17-
Ok(s) => s.status.success(),
18-
_ => false,
19-
};
20-
if !has_wasmtime {
21-
println!("skipping test, wasmtime isn't available");
22-
return;
23-
}
24-
2515
run(&file, "return_two_i32", "1\n2\n");
2616
run(&file, "return_two_i64", "3\n4\n");
2717
run(&file, "return_two_f32", "5\n6\n");

‎tests/run-make/wasm-custom-section/rmake.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
1+
//@ only-wasm32-wasip1
12
extern crate run_make_support;
23

34
use run_make_support::{rustc, tmp_dir, wasmparser};
45
use std::collections::HashMap;
56

67
fn main() {
7-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
8-
return;
9-
}
10-
118
rustc().input("foo.rs").target("wasm32-wasip1").run();
129
rustc().input("bar.rs").target("wasm32-wasip1").arg("-Clto").opt().run();
1310

‎tests/run-make/wasm-custom-sections-opt/rmake.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
//@ only-wasm32-wasip1
12
extern crate run_make_support;
23

34
use run_make_support::{tmp_dir, wasmparser, rustc};
45
use std::collections::HashMap;
56
use std::path::Path;
67

78
fn main() {
8-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
9-
return;
10-
}
11-
129
rustc().input("foo.rs").target("wasm32-wasip1").opt().run();
1310

1411
verify(&tmp_dir().join("foo.wasm"));

‎tests/run-make/wasm-export-all-symbols/rmake.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//@ only-wasm32-wasip1
2+
13
extern crate run_make_support;
24

35
use run_make_support::{tmp_dir, wasmparser, rustc};
@@ -6,10 +8,6 @@ use std::path::Path;
68
use wasmparser::ExternalKind::*;
79

810
fn main() {
9-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
10-
return;
11-
}
12-
1311
test(&[]);
1412
test(&["-O"]);
1513
test(&["-Clto"]);

‎tests/run-make/wasm-import-module/rmake.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1+
//@ only-wasm32-wasip1
2+
13
extern crate run_make_support;
24

35
use run_make_support::{tmp_dir, wasmparser, rustc};
46
use std::collections::HashMap;
57
use wasmparser::TypeRef::Func;
68

79
fn main() {
8-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
9-
return;
10-
}
11-
1210
rustc().input("foo.rs").target("wasm32-wasip1").run();
1311
rustc()
1412
.input("bar.rs")

‎tests/run-make/wasm-panic-small/rmake.rs‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,11 @@
1+
//@ only-wasm32-wasip1
12
#![deny(warnings)]
23

34
extern crate run_make_support;
45

56
use run_make_support::{rustc, tmp_dir};
67

78
fn main() {
8-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
9-
return;
10-
}
11-
129
test("a");
1310
test("b");
1411
test("c");

‎tests/run-make/wasm-spurious-import/rmake.rs‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1+
//@ only-wasm32-wasip1
2+
13
extern crate run_make_support;
24

35
use run_make_support::{rustc, tmp_dir, wasmparser};
46
use std::collections::HashMap;
57

68
fn main() {
7-
if std::env::var("TARGET").unwrap() != "wasm32-wasip1" {
8-
return;
9-
}
10-
119
rustc()
1210
.input("main.rs")
1311
.target("wasm32-wasip1")

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /