Horki opened Issue #2438:
Example 1
I have written a gcd unit tests intogcd.wast
(module ;; Do I need this header? (import "gcd" "gcd" (func $gcd (param i32) (param i32) (result i32))) ) (assert_return (invoke "gcd" (i32.const 27) (i32.const 6)) (i32.const 3)) (assert_return (invoke "gcd" (i32.const 6) (i32.const 27)) (i32.const 3))
And I want to run wast file from CLI, with importing wat file.
wasmtime --import gcd.wat wast gcd.wast
Example 2
Linking exampleHow can I do this?
wasmtime --import examples/linking2.wat run examples/linking1.wat
alexcrichton commented on Issue #2438:
I think you might be looking for the
--preload
CLI option? That allows loading modules under specific names I think for this use case
Horki commented on Issue #2438:
Hi @alexcrichton ,
--preload
currently only works withrun
command, but it's missing inwast
commandMeaning
example2
is working;# Example 2 ! Works $ wasmtime run --preload linking2=examples/linking2.wat examples/linking1.wat --invoke run # Not working for wast command $ wasmtime wast --preload gcd=examples/gcd.wat gcd.wast > Found argument '--preload' which wasn't expected, or isn't valid in this context
What would be the proper way to
preload
while using wast for unit testing?
Horki edited a comment on Issue #2438:
Hi @alexcrichton ,
--preload
currently only works withrun
command, but it's missing inwast
commandMeaning
example2
is working;# Example 2 ! Works $ wasmtime run --preload linking2=examples/linking2.wat examples/linking1.wat --invoke run # Not working for wast command $ wasmtime wast --preload gcd=examples/gcd.wat gcd.wast > Found argument '--preload' which wasn't expected, or isn't valid in this context
What would be the proper way to
preload
while using wast for unit testing?EDIT:
I know I could do a manual hack, and add fieldpreload
here, but that would be VERY WRONG IMGO
Horki edited a comment on Issue #2438:
Hi @alexcrichton ,
--preload
currently only works withrun
command, but it's missing inwast
commandMeaning
example2
is working;# Example 2 ! Works $ wasmtime run --preload linking2=examples/linking2.wat examples/linking1.wat --invoke run # Not working for wast command $ wasmtime wast --preload gcd=examples/gcd.wat gcd.wast > Found argument '--preload' which wasn't expected, or isn't valid in this context
What would be the proper way to
preload
while using wast for unit testing?EDIT:
I know I could do a manual hack, and add fieldpreload
here, but that would be VERY WRONG IMHO
alexcrichton commented on Issue #2438:
Ah sorry I missed that! I believe that the
wast
command doesn't have support for this yet but it probably wouldn't be too hard to do so!
Horki commented on Issue #2438:
@alexcrichton
Ok, I've got it, no need for
preload
in my case
gcd.wast
(assert_return (invoke "gcd" (i32.const 27) (i32.const 6)) (i32.const 3)) (assert_return (invoke "gcd" (i32.const 6) (i32.const 27)) (i32.const 3))
# This will run $ wasmtime wast examples/gcd.wat gcd.wast
Horki closed Issue #2438:
Example 1
I have written a gcd unit tests intogcd.wast
(module ;; Do I need this header? (import "gcd" "gcd" (func $gcd (param i32) (param i32) (result i32))) ) (assert_return (invoke "gcd" (i32.const 27) (i32.const 6)) (i32.const 3)) (assert_return (invoke "gcd" (i32.const 6) (i32.const 27)) (i32.const 3))
And I want to run wast file from CLI, with importing wat file.
wasmtime --import gcd.wat wast gcd.wast
Example 2
Linking exampleHow can I do this?
wasmtime --import examples/linking2.wat run examples/linking1.wat
Last updated: Dec 23 2024 at 12:05 UTC