Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 19 additions & 52 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion crates/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ anyhow = { workspace = true }
clap = { workspace = true, features = ['env'] }
heck = { workspace = true }
log = "0.4.26"
rayon = "1.10.0"
regex = "1.11.1"
serde = { workspace = true }
toml = "0.8.20"
Expand All @@ -39,3 +38,4 @@ wat = { workspace = true }
wit-component = { workspace = true }
wit-parser = { workspace = true }
wit-bindgen-csharp = { workspace = true }
libtest-mimic = "0.8.1"
16 changes: 8 additions & 8 deletions crates/test/src/c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ struct LangConfig {
ldflags: StringList,
}

fn clang(runner: &Runner<'_>) -> PathBuf {
fn clang(runner: &Runner) -> PathBuf {
let target = &runner.opts.c.c_target;
match &runner.opts.c.wasi_sdk_path {
Some(path) => path.join(format!("bin/{target}-clang")),
Expand Down Expand Up @@ -67,20 +67,20 @@ impl LanguageMethods for C {
]
}

fn prepare(&self, runner: &mut Runner<'_>) -> Result<()> {
fn prepare(&self, runner: &mut Runner) -> Result<()> {
prepare(runner, clang(runner))
}

fn compile(&self, runner: &Runner<'_>, c: &Compile<'_>) -> Result<()> {
fn compile(&self, runner: &Runner, c: &Compile<'_>) -> Result<()> {
compile(runner, c, clang(runner))
}

fn verify(&self, runner: &Runner<'_>, v: &Verify<'_>) -> Result<()> {
fn verify(&self, runner: &Runner, v: &Verify<'_>) -> Result<()> {
verify(runner, v, clang(runner))
}
}

fn prepare(runner: &mut Runner<'_>, compiler: PathBuf) -> Result<()> {
fn prepare(runner: &mut Runner, compiler: PathBuf) -> Result<()> {
let cwd = env::current_dir()?;
let dir = cwd.join(&runner.opts.artifacts).join("c");

Expand All @@ -99,7 +99,7 @@ fn prepare(runner: &mut Runner<'_>, compiler: PathBuf) -> Result<()> {
Ok(())
}

fn compile(runner: &Runner<'_>, compile: &Compile<'_>, compiler: PathBuf) -> Result<()> {
fn compile(runner: &Runner, compile: &Compile<'_>, compiler: PathBuf) -> Result<()> {
let config = compile.component.deserialize_lang_config::<LangConfig>()?;

// Compile the C-based bindings to an object file.
Expand Down Expand Up @@ -162,14 +162,14 @@ fn compile(runner: &Runner<'_>, compile: &Compile<'_>, compiler: PathBuf) -> Res
Ok(())
}

fn produces_component(runner: &Runner<'_>) -> bool {
fn produces_component(runner: &Runner) -> bool {
match runner.opts.c.c_target.as_str() {
"wasm32-wasip1" => false,
_ => true,
}
}

fn verify(runner: &Runner<'_>, verify: &Verify<'_>, compiler: PathBuf) -> Result<()> {
fn verify(runner: &Runner, verify: &Verify<'_>, compiler: PathBuf) -> Result<()> {
let mut cmd = Command::new(compiler);
cmd.arg(
verify
Expand Down
10 changes: 5 additions & 5 deletions crates/test/src/cpp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct LangConfig {
cflags: StringList,
}

fn clangpp(runner: &Runner<'_>) -> PathBuf {
fn clangpp(runner: &Runner) -> PathBuf {
match &runner.opts.c.wasi_sdk_path {
Some(path) => path.join("bin/wasm32-wasip2-clang++"),
None => "wasm32-wasip2-clang++".into(),
Expand Down Expand Up @@ -57,7 +57,7 @@ impl LanguageMethods for Cpp {
}
}

fn prepare(&self, runner: &mut crate::Runner<'_>) -> anyhow::Result<()> {
fn prepare(&self, runner: &mut Runner) -> anyhow::Result<()> {
let compiler = clangpp(runner);
let cwd = std::env::current_dir()?;
let dir = cwd.join(&runner.opts.artifacts).join("cpp");
Expand All @@ -79,7 +79,7 @@ impl LanguageMethods for Cpp {

fn generate_bindings_prepare(
&self,
_runner: &Runner<'_>,
_runner: &Runner,
bindgen: &crate::Bindgen,
dir: &std::path::Path,
) -> anyhow::Result<()> {
Expand All @@ -106,7 +106,7 @@ impl LanguageMethods for Cpp {
Ok(())
}

fn compile(&self, runner: &crate::Runner<'_>, compile: &crate::Compile) -> anyhow::Result<()> {
fn compile(&self, runner: &Runner, compile: &crate::Compile) -> anyhow::Result<()> {
let compiler = clangpp(runner);
let config = compile.component.deserialize_lang_config::<LangConfig>()?;

Expand Down Expand Up @@ -180,7 +180,7 @@ impl LanguageMethods for Cpp {
Ok(())
}

fn verify(&self, runner: &crate::Runner<'_>, verify: &crate::Verify) -> anyhow::Result<()> {
fn verify(&self, runner: &Runner, verify: &crate::Verify) -> anyhow::Result<()> {
// for expected
let cwd = std::env::current_dir()?;
let mut helper_dir2 = cwd;
Expand Down
6 changes: 3 additions & 3 deletions crates/test/src/csharp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ impl LanguageMethods for Csharp {
)
}

fn prepare(&self, runner: &mut Runner<'_>) -> Result<()> {
fn prepare(&self, runner: &mut Runner) -> Result<()> {
runner.run_command(dotnet().arg("--version"))?;

Ok(())
}

fn compile(&self, runner: &Runner<'_>, compile: &Compile<'_>) -> Result<()> {
fn compile(&self, runner: &Runner, compile: &Compile<'_>) -> Result<()> {
let world_name = &compile.component.bindgen.world;
let path = &compile.component.path;
let test_dir = &compile.bindings_dir;
Expand Down Expand Up @@ -113,7 +113,7 @@ impl LanguageMethods for Csharp {
Ok(())
}

fn verify(&self, runner: &Runner<'_>, verify: &Verify<'_>) -> Result<()> {
fn verify(&self, runner: &Runner, verify: &Verify<'_>) -> Result<()> {
let dir = verify.bindings_dir;
let name = verify.world;
let mut project = wit_bindgen_csharp::CSProject::new(dir.to_path_buf(), &name, "the_world");
Expand Down
10 changes: 5 additions & 5 deletions crates/test/src/custom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ pub struct Language {
}

impl Language {
pub fn lookup(runner: &Runner<'_>, language: &str) -> Result<Language> {
pub fn lookup(runner: &Runner, language: &str) -> Result<Language> {
for (ext, script) in runner.opts.custom.custom.iter() {
if ext == language {
return Ok(Language {
Expand Down Expand Up @@ -108,7 +108,7 @@ impl LanguageMethods for Language {
false
}

fn generate_bindings(&self, runner: &Runner<'_>, bindgen: &Bindgen, dir: &Path) -> Result<()> {
fn generate_bindings(&self, runner: &Runner, bindgen: &Bindgen, dir: &Path) -> Result<()> {
runner.run_command(
Command::new(&self.script)
.arg("bindgen")
Expand All @@ -117,7 +117,7 @@ impl LanguageMethods for Language {
)
}

fn prepare(&self, runner: &mut Runner<'_>) -> Result<()> {
fn prepare(&self, runner: &mut Runner) -> Result<()> {
let dir = env::current_dir()?
.join(&runner.opts.artifacts)
.join(&self.extension);
Expand All @@ -128,7 +128,7 @@ impl LanguageMethods for Language {
)
}

fn compile(&self, runner: &Runner<'_>, compile: &Compile<'_>) -> Result<()> {
fn compile(&self, runner: &Runner, compile: &Compile<'_>) -> Result<()> {
let dir = env::current_dir()?
.join(&runner.opts.artifacts)
.join(&self.extension);
Expand All @@ -144,7 +144,7 @@ impl LanguageMethods for Language {
)
}

fn verify(&self, runner: &Runner<'_>, verify: &Verify<'_>) -> Result<()> {
fn verify(&self, runner: &Runner, verify: &Verify<'_>) -> Result<()> {
runner.run_command(
Command::new(&self.script)
.arg("verify")
Expand Down
8 changes: 4 additions & 4 deletions crates/test/src/go.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl LanguageMethods for Go {
&["--generate-stubs"]
}

fn prepare(&self, runner: &mut Runner<'_>) -> Result<()> {
fn prepare(&self, runner: &mut Runner) -> Result<()> {
let cwd = env::current_dir()?;
let dir = cwd.join(&runner.opts.artifacts).join("go");
let bindings_dir = cwd.join("wit_component");
Expand All @@ -56,7 +56,7 @@ impl LanguageMethods for Go {
)
}

fn compile(&self, runner: &Runner<'_>, compile: &Compile<'_>) -> Result<()> {
fn compile(&self, runner: &Runner, compile: &Compile<'_>) -> Result<()> {
let output = compile.output.with_extension("core.wasm");

// Tests which involve importing and/or exporting more than one
Expand Down Expand Up @@ -96,7 +96,7 @@ impl LanguageMethods for Go {
Ok(())
}

fn verify(&self, runner: &Runner<'_>, verify: &Verify<'_>) -> Result<()> {
fn verify(&self, runner: &Runner, verify: &Verify<'_>) -> Result<()> {
replace_bindings_go_mod(runner, verify.bindings_dir)?;

runner.run_command(
Expand Down Expand Up @@ -152,7 +152,7 @@ fn all_paths(path: &Path) -> Result<Vec<PathBuf>> {
Ok(paths)
}

fn replace_bindings_go_mod(runner: &Runner<'_>, bindings_dir: &Path) -> Result<()> {
fn replace_bindings_go_mod(runner: &Runner, bindings_dir: &Path) -> Result<()> {
let test_crate = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
let wit_bindgen_root = test_crate.parent().unwrap().parent().unwrap();
let go_package_path = wit_bindgen_root.join("crates/go/src/package");
Expand Down
Loading
Loading