about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2024-03-06 12:39:07 -0800
committerAlex Crichton <alex@alexcrichton.com>2024-03-11 09:36:35 -0700
commit7141379559e2ef17e48dfbadc898581cd34bef6f (patch)
tree626bcaef1d4ed48bb18c8ebb63851ba2e4db6be9 /src
parentd255c6a57c393db6221b1ff700daea478436f1cd (diff)
downloadrust-7141379559e2ef17e48dfbadc898581cd34bef6f.tar.gz
rust-7141379559e2ef17e48dfbadc898581cd34bef6f.zip
Convert some WebAssembly run-make tests to Rust
This commit rewrites a number of `run-make` tests centered around wasm
to instead use `rmake.rs` and additionally use the `wasm32-wasip1`
target instead of `wasm32-unknown-unknown`. Testing no longer requires
Node.js and additionally uses the `wasmparser` crate from crates.io to
parse outputs and power assertions.
Diffstat (limited to 'src')
-rw-r--r--src/tools/run-make-support/Cargo.toml1
-rw-r--r--src/tools/run-make-support/src/lib.rs16
2 files changed, 13 insertions, 4 deletions
diff --git a/src/tools/run-make-support/Cargo.toml b/src/tools/run-make-support/Cargo.toml
index 178deae6499..958aef69572 100644
--- a/src/tools/run-make-support/Cargo.toml
+++ b/src/tools/run-make-support/Cargo.toml
@@ -4,3 +4,4 @@ version = "0.0.0"
 edition = "2021"
 
 [dependencies]
+wasmparser = "0.118.2"
diff --git a/src/tools/run-make-support/src/lib.rs b/src/tools/run-make-support/src/lib.rs
index 820218732ce..674860f8413 100644
--- a/src/tools/run-make-support/src/lib.rs
+++ b/src/tools/run-make-support/src/lib.rs
@@ -2,13 +2,16 @@ use std::env;
 use std::path::{Path, PathBuf};
 use std::process::{Command, Output};
 
+pub use wasmparser;
+
+pub fn out_dir() -> PathBuf {
+    env::var_os("TMPDIR").unwrap().into()
+}
+
 fn setup_common_build_cmd() -> Command {
     let rustc = env::var("RUSTC").unwrap();
     let mut cmd = Command::new(rustc);
-    cmd.arg("--out-dir")
-        .arg(env::var("TMPDIR").unwrap())
-        .arg("-L")
-        .arg(env::var("TMPDIR").unwrap());
+    cmd.arg("--out-dir").arg(out_dir()).arg("-L").arg(out_dir());
     cmd
 }
 
@@ -45,6 +48,11 @@ impl RustcInvocationBuilder {
         self
     }
 
+    pub fn args(&mut self, args: &[&str]) -> &mut RustcInvocationBuilder {
+        self.cmd.args(args);
+        self
+    }
+
     #[track_caller]
     pub fn run(&mut self) -> Output {
         let caller_location = std::panic::Location::caller();