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
2 changes: 2 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,7 @@ fn main() {
println!("cargo:rerun-if-changed=providers/javy_quickjs_provider_v3.wasm");
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v1.wasm");
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v2.wasm");
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v3.wasm");
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v4.wasm");
println!("cargo:rerun-if-changed=providers/shopify_function_v1.wasm");
}
Binary file added providers/shopify_functions_javy_v4.wasm
Binary file not shown.
5 changes: 5 additions & 0 deletions tests/fixtures/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ js_function_javy_plugin_v3.wasm:
javy build -C dynamic -C plugin=providers/shopify_functions_javy_v3.wasm -o tests/fixtures/build/js_function_javy_plugin_v3.wasm tests/fixtures/js_function_javy_plugin_v3/function.js
```

js_function_javy_plugin_v4.wasm:
```
javy build -C dynamic -C plugin=providers/shopify_functions_javy_v4.wasm -o tests/fixtures/build/js_function_javy_plugin_v4.wasm tests/fixtures/js_function_javy_plugin_v4/function.js
```

**`*.wat` examples:**
```
find tests/fixtures -maxdepth 1 -type f -name "*.wat" \
Expand Down
Binary file added tests/fixtures/build/js_function_javy_plugin_v4.wasm
Binary file not shown.
4 changes: 4 additions & 0 deletions tests/fixtures/js_function_javy_plugin_v4/function.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
const inputObj = ShopifyFunction.readInput();
console.error("this is an error message");
const outputObj = { hello: inputObj.hello + " output" };
ShopifyFunction.writeOutput(outputObj);
31 changes: 19 additions & 12 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,21 +438,28 @@ mod tests {

#[test]
fn run_javy_plugin_v3() -> Result<()> {
run_javy_plugin_fixture("tests/fixtures/build/js_function_javy_plugin_v3.wasm")
}

#[test]
fn run_javy_plugin_v4() -> Result<()> {
run_javy_plugin_fixture("tests/fixtures/build/js_function_javy_plugin_v4.wasm")
}

fn run_javy_plugin_fixture(function_path: &str) -> Result<()> {
let mut cmd = Command::new(cargo_bin!());
let input = temp_input(json!({"hello": "world"}))?;

cmd.args([
"--function",
"tests/fixtures/build/js_function_javy_plugin_v3.wasm",
])
.arg("--json")
.arg("--input")
.arg(input.as_os_str())
.stdout(Stdio::piped())
.spawn()
.expect("Failed to spawn child process")
.wait_with_output()
.expect("Failed waiting for output");
cmd.arg("--function")
.arg(function_path)
.arg("--json")
.arg("--input")
.arg(input.as_os_str())
.stdout(Stdio::piped())
.spawn()
.expect("Failed to spawn child process")
.wait_with_output()
.expect("Failed waiting for output");

// Command should succeed
cmd.assert().success();
Expand Down
Loading