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.wastExample 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
--preloadCLI option? That allows loading modules under specific names I think for this use case
Horki commented on Issue #2438:
Hi @alexcrichton ,
--preloadcurrently only works withruncommand, but it's missing inwastcommandMeaning
example2is 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 contextWhat would be the proper way to
preloadwhile using wast for unit testing?
Horki edited a comment on Issue #2438:
Hi @alexcrichton ,
--preloadcurrently only works withruncommand, but it's missing inwastcommandMeaning
example2is 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 contextWhat would be the proper way to
preloadwhile using wast for unit testing?EDIT:
I know I could do a manual hack, and add fieldpreloadhere, but that would be VERY WRONG IMGO
Horki edited a comment on Issue #2438:
Hi @alexcrichton ,
--preloadcurrently only works withruncommand, but it's missing inwastcommandMeaning
example2is 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 contextWhat would be the proper way to
preloadwhile using wast for unit testing?EDIT:
I know I could do a manual hack, and add fieldpreloadhere, but that would be VERY WRONG IMHO
alexcrichton commented on Issue #2438:
Ah sorry I missed that! I believe that the
wastcommand 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
preloadin 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.wastExample 2
Linking exampleHow can I do this?
wasmtime --import examples/linking2.wat run examples/linking1.wat
Last updated: Dec 13 2025 at 19:03 UTC