-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* init test generation * run the wasi test * split test dir up into subcomponents * first pass at test codegen * update test generation * generate tests * fix newline issues
- Loading branch information
1 parent
22ad066
commit 5f321ef
Showing
98 changed files
with
1,621 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[package] | ||
name = "test-utils" | ||
authors = ["Yosh Wuyts <[email protected]>", "Guy Bedford <[email protected]>"] | ||
publish = false | ||
|
||
version = { workspace = true } | ||
edition = { workspace = true } | ||
|
||
[dependencies] | ||
anyhow = { workspace = true } | ||
xshell = { workspace = true } | ||
tempdir = { workspace = true } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use anyhow::anyhow; | ||
use std::{fs::File, path::PathBuf}; | ||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
/// Compile a `.wasm` file to `.wasm.component` file using `jco`. | ||
pub fn compile(sh: &Shell, tmpdir: &TempDir, file_name: &str) -> anyhow::Result<PathBuf> { | ||
let src_file: PathBuf = | ||
format!("./submodules/wasmtime/target/wasm32-wasi/release/{file_name}.wasm").parse()?; | ||
if !src_file.exists() { | ||
return Err(anyhow!("src: {src_file:?} does not exists on disk")); | ||
} | ||
|
||
let out_dir = tmpdir.path(); | ||
let dest_file = out_dir.join(format!("{file_name}.component.wasm")); | ||
File::create(&dest_file)?; | ||
|
||
cmd!( | ||
sh, | ||
"./src/jco.js new {src_file} --wasi-command -o {dest_file}" | ||
) | ||
.run()?; | ||
|
||
Ok(dest_file) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn api_proxy() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "api_proxy"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn api_reactor() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "api_reactor"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn api_read_only() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "api_read_only"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn api_time() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "api_time"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_args() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_args"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_default_clocks() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_default_clocks"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_directory_list() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_directory_list"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_env() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_env"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_exit_default() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_exit_default"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_exit_failure() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_exit_failure"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_exit_panic() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_exit_panic"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_exit_success() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_exit_success"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
//! This file has been auto-generated, please do not modify manually | ||
//! To regenerate this file re-run `cargo xtask generate tests` from the project root | ||
|
||
use tempdir::TempDir; | ||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn cli_export_cabi_realloc() -> anyhow::Result<()> { | ||
let sh = Shell::new()?; | ||
let file_name = "cli_export_cabi_realloc"; | ||
let tempdir = TempDir::new("{file_name}")?; | ||
let wasi_file = test_utils::compile(&sh, &tempdir, &file_name)?; | ||
cmd!(sh, "./src/jco.js run {wasi_file}").run()?; | ||
Ok(()) | ||
} |
Oops, something went wrong.