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>
24 lines
599 B
Go
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)
|
|
})
|
|
}
|
|
}
|