Skip to content

Commit 8bc9da0

Browse files
authored
Add shopify_functions_javy_plugin_v4 (#586)
1 parent 511a20b commit 8bc9da0

6 files changed

Lines changed: 30 additions & 12 deletions

File tree

build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,7 @@ fn main() {
44
println!("cargo:rerun-if-changed=providers/javy_quickjs_provider_v3.wasm");
55
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v1.wasm");
66
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v2.wasm");
7+
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v3.wasm");
8+
println!("cargo:rerun-if-changed=providers/shopify_functions_javy_v4.wasm");
79
println!("cargo:rerun-if-changed=providers/shopify_function_v1.wasm");
810
}
1.18 MB
Binary file not shown.

tests/fixtures/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,11 @@ js_function_javy_plugin_v3.wasm:
4343
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
4444
```
4545

46+
js_function_javy_plugin_v4.wasm:
47+
```
48+
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
49+
```
50+
4651
**`*.wat` examples:**
4752
```
4853
find tests/fixtures -maxdepth 1 -type f -name "*.wat" \
671 Bytes
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
const inputObj = ShopifyFunction.readInput();
2+
console.error("this is an error message");
3+
const outputObj = { hello: inputObj.hello + " output" };
4+
ShopifyFunction.writeOutput(outputObj);

tests/integration_tests.rs

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -438,21 +438,28 @@ mod tests {
438438

439439
#[test]
440440
fn run_javy_plugin_v3() -> Result<()> {
441+
run_javy_plugin_fixture("tests/fixtures/build/js_function_javy_plugin_v3.wasm")
442+
}
443+
444+
#[test]
445+
fn run_javy_plugin_v4() -> Result<()> {
446+
run_javy_plugin_fixture("tests/fixtures/build/js_function_javy_plugin_v4.wasm")
447+
}
448+
449+
fn run_javy_plugin_fixture(function_path: &str) -> Result<()> {
441450
let mut cmd = Command::new(cargo_bin!());
442451
let input = temp_input(json!({"hello": "world"}))?;
443452

444-
cmd.args([
445-
"--function",
446-
"tests/fixtures/build/js_function_javy_plugin_v3.wasm",
447-
])
448-
.arg("--json")
449-
.arg("--input")
450-
.arg(input.as_os_str())
451-
.stdout(Stdio::piped())
452-
.spawn()
453-
.expect("Failed to spawn child process")
454-
.wait_with_output()
455-
.expect("Failed waiting for output");
453+
cmd.arg("--function")
454+
.arg(function_path)
455+
.arg("--json")
456+
.arg("--input")
457+
.arg(input.as_os_str())
458+
.stdout(Stdio::piped())
459+
.spawn()
460+
.expect("Failed to spawn child process")
461+
.wait_with_output()
462+
.expect("Failed waiting for output");
456463

457464
// Command should succeed
458465
cmd.assert().success();

0 commit comments

Comments
 (0)