diff --git a/build.rs b/build.rs index a4890c76..b8c784fb 100644 --- a/build.rs +++ b/build.rs @@ -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"); } diff --git a/providers/shopify_functions_javy_v4.wasm b/providers/shopify_functions_javy_v4.wasm new file mode 100644 index 00000000..ab49dbc0 Binary files /dev/null and b/providers/shopify_functions_javy_v4.wasm differ diff --git a/tests/fixtures/README.md b/tests/fixtures/README.md index 91c4f45c..b5b6fe03 100644 --- a/tests/fixtures/README.md +++ b/tests/fixtures/README.md @@ -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" \ diff --git a/tests/fixtures/build/js_function_javy_plugin_v4.wasm b/tests/fixtures/build/js_function_javy_plugin_v4.wasm new file mode 100644 index 00000000..0f7c9816 Binary files /dev/null and b/tests/fixtures/build/js_function_javy_plugin_v4.wasm differ diff --git a/tests/fixtures/js_function_javy_plugin_v4/function.js b/tests/fixtures/js_function_javy_plugin_v4/function.js new file mode 100644 index 00000000..3cf088f6 --- /dev/null +++ b/tests/fixtures/js_function_javy_plugin_v4/function.js @@ -0,0 +1,4 @@ +const inputObj = ShopifyFunction.readInput(); +console.error("this is an error message"); +const outputObj = { hello: inputObj.hello + " output" }; +ShopifyFunction.writeOutput(outputObj); diff --git a/tests/integration_tests.rs b/tests/integration_tests.rs index 46120b0d..5baa864a 100644 --- a/tests/integration_tests.rs +++ b/tests/integration_tests.rs @@ -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();