Skip to content

Commit f693634

Browse files
committed
Fix tests on Rust nightly
The build directory layout of Cargo is changing so this updates the build/run of Rust tests to read the JSON messages from Cargo about where artifacts are located.
1 parent d92cfd3 commit f693634

12 files changed

Lines changed: 86 additions & 43 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ bitflags = "2.11.1"
4040
heck = { version = "0.5" }
4141
pulldown-cmark = { version = "0.13.3", default-features = false }
4242
serde = { version = "1.0.228", features = ["derive"] }
43+
serde_json = { version = "1" }
4344
clap = { version = "4.6.1", features = ["derive"] }
4445
indexmap = "2.0.0"
4546
prettyplease = "0.2.20"

crates/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ futures = { workspace = true }
3939
wit-bindgen = { path = '../guest-rust', features = ['async'] }
4040
test-helpers = { path = '../test-helpers' }
4141
# For use with the custom attributes test
42-
serde_json = "1"
42+
serde_json = { workspace = true }
4343
bytes = "1"
4444

4545
[features]

crates/test/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ heck = { workspace = true }
2525
log = "0.4.26"
2626
regex = "1.11.1"
2727
serde = { workspace = true }
28+
serde_json = { workspace = true }
2829
toml = "1.1.2"
2930
wasi-preview1-component-adapter-provider = "46.0.1"
3031
wac-parser = "0.10.0"

crates/test/src/c.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,5 +187,6 @@ fn verify(runner: &Runner, verify: &Verify<'_>, compiler: PathBuf) -> Result<()>
187187
.arg("-c")
188188
.arg("-o")
189189
.arg(verify.artifacts_dir.join("tmp.o"));
190-
runner.run_command(&mut cmd)
190+
runner.run_command(&mut cmd)?;
191+
Ok(())
191192
}

crates/test/src/cpp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ impl LanguageMethods for Cpp {
207207
.arg("-c")
208208
.arg("-o")
209209
.arg(verify.artifacts_dir.join("tmp.o"));
210-
runner.run_command(&mut cmd)
210+
runner.run_command(&mut cmd)?;
211+
Ok(())
211212
}
212213
}

crates/test/src/csharp.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ impl LanguageMethods for Csharp {
144144
.arg(&wasm_filename);
145145
runner.run_command(&mut cmd)?;
146146

147-
runner.run_command(dotnet().current_dir(&dir).arg("clean"))
147+
runner.run_command(dotnet().current_dir(&dir).arg("clean"))?;
148+
Ok(())
148149
}
149150
}

crates/test/src/custom.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ impl LanguageMethods for Language {
115115
.arg("bindgen")
116116
.env("WIT", &bindgen.wit_path)
117117
.env("BINDINGS_DIR", dir),
118-
)
118+
)?;
119+
Ok(())
119120
}
120121

121122
fn prepare(&self, runner: &mut Runner) -> Result<()> {
@@ -126,7 +127,8 @@ impl LanguageMethods for Language {
126127
Command::new(&self.script)
127128
.arg("prepare")
128129
.env("PREP_DIR", &dir),
129-
)
130+
)?;
131+
Ok(())
130132
}
131133

132134
fn compile(&self, runner: &Runner, compile: &Compile<'_>) -> Result<()> {
@@ -142,7 +144,8 @@ impl LanguageMethods for Language {
142144
.env("BINDINGS_DIR", &compile.bindings_dir)
143145
.env("ARTIFACTS_DIR", &compile.artifacts_dir)
144146
.env("OUTPUT", &compile.output),
145-
)
147+
)?;
148+
Ok(())
146149
}
147150

148151
fn verify(&self, runner: &Runner, verify: &Verify<'_>) -> Result<()> {
@@ -152,6 +155,7 @@ impl LanguageMethods for Language {
152155
.env("WIT", verify.wit_test)
153156
.env("BINDINGS_DIR", &verify.bindings_dir)
154157
.env("ARTIFACTS_DIR", &verify.artifacts_dir),
155-
)
158+
)?;
159+
Ok(())
156160
}
157161
}

crates/test/src/go.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,8 @@ func main() {}
190190
.arg(verify.artifacts_dir.join("tmp.wasm"))
191191
.arg("-buildmode=c-shared")
192192
.arg("-ldflags=-checklinkname=0"),
193-
)
193+
)?;
194+
Ok(())
194195
}
195196
}
196197

crates/test/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,15 +1049,15 @@ impl Runner {
10491049

10501050
/// Helper to execute an external process and generate a helpful error
10511051
/// message on failure.
1052-
fn run_command(&self, cmd: &mut Command) -> Result<()> {
1052+
fn run_command(&self, cmd: &mut Command) -> Result<String> {
10531053
if self.opts.inherit_stderr {
10541054
cmd.stderr(Stdio::inherit());
10551055
}
10561056
let output = cmd
10571057
.output()
10581058
.with_context(|| format!("failed to spawn {cmd:?}"))?;
10591059
if output.status.success() {
1060-
return Ok(());
1060+
return Ok(String::from_utf8_lossy(&output.stdout).into());
10611061
}
10621062

10631063
let mut error = format!(
@@ -1256,7 +1256,8 @@ trait LanguageMethods {
12561256
cmd.arg(arg);
12571257
}
12581258

1259-
runner.run_command(&mut cmd)
1259+
runner.run_command(&mut cmd)?;
1260+
Ok(())
12601261
}
12611262

12621263
/// Returns the default set of arguments that will be passed to

0 commit comments

Comments
 (0)