Files
wazero/examples/wasi/cat_test.go
Crypt Keeper f0e05fb95b examples: adds rust build and WASI example (#676)
This fixes where our pull requests didn't check the rust source in
examples were valid. It also adds an example of wasi with rust.

This uses cargo-wasi because the default target creates almost 2MB of
wasm for a simple cat program.

Signed-off-by: Adrian Cole <adrian@tetrate.io>
2022-07-08 10:49:50 +08:00

24 lines
599 B
Go

package main
import (
"testing"
"github.com/tetratelabs/wazero/internal/testing/maintester"
"github.com/tetratelabs/wazero/internal/testing/require"
)
// Test_main ensures the following will work:
//
// go run cat.go /test.txt
func Test_main(t *testing.T) {
for _, toolchain := range []string{"cargo-wasi", "tinygo", "zig-cc"} {
toolchain := toolchain
t.Run(toolchain, func(t *testing.T) {
t.Setenv("TOOLCHAIN", toolchain)
stdout, stderr := maintester.TestMain(t, main, "cat", "/test.txt")
require.Equal(t, "", stderr)
require.Equal(t, "greet filesystem\n", stdout)
})
}
}