diff options
author | Ayke van Laethem <[email protected]> | 2023-08-10 22:36:35 +0200 |
---|---|---|
committer | Ron Evans <[email protected]> | 2023-08-17 18:16:54 +0200 |
commit | a545f17d2ea55807de4b97cf4f52f01d5d4f1815 (patch) | |
tree | 075ea83380859d7604f67ca4dbaafc7ff76f4e90 /main_test.go | |
parent | f4375d045213c416fad2d19773e7700b6b02f685 (diff) | |
download | tinygo-a545f17d2ea55807de4b97cf4f52f01d5d4f1815.tar.gz tinygo-a545f17d2ea55807de4b97cf4f52f01d5d4f1815.zip |
wasm: add support for GOOS=wasip1
This adds true GOOS=wasip1 support in addition to our existing
-target=wasi support. The old support for WASI isn't removed, but should
be treated as deprecated and will likely be removed eventually to reduce
the test burden.
Diffstat (limited to 'main_test.go')
-rw-r--r-- | main_test.go | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/main_test.go b/main_test.go index 32d13f910..ae7aed564 100644 --- a/main_test.go +++ b/main_test.go @@ -34,6 +34,16 @@ var supportedLinuxArches = map[string]string{ "X86Linux": "linux/386", "ARMLinux": "linux/arm/6", "ARM64Linux": "linux/arm64", + "WASIp1": "wasip1/wasm", +} + +func init() { + major, _, _ := goenv.GetGorootVersion() + if major < 21 { + // Go 1.20 backwards compatibility. + // Should be removed once we drop support for Go 1.20. + delete(supportedLinuxArches, "WASIp1") + } } var sema = make(chan struct{}, runtime.NumCPU()) @@ -176,6 +186,8 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) { t.Fatal("failed to load target spec:", err) } + isWebAssembly := options.Target == "wasi" || options.Target == "wasm" || (options.Target == "" && options.GOARCH == "wasm") + for _, name := range tests { if options.GOOS == "linux" && (options.GOARCH == "arm" || options.GOARCH == "386") { switch name { @@ -226,7 +238,7 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) { runTest("env.go", options, t, []string{"first", "second"}, []string{"ENV1=VALUE1", "ENV2=VALUE2"}) }) } - if options.Target == "wasi" || options.Target == "wasm" { + if isWebAssembly { t.Run("alias.go-scheduler-none", func(t *testing.T) { t.Parallel() options := compileopts.Options(options) @@ -246,7 +258,7 @@ func runPlatTests(options compileopts.Options, tests []string, t *testing.T) { runTest("rand.go", options, t, nil, nil) }) } - if options.Target != "wasi" && options.Target != "wasm" { + if !isWebAssembly { // The recover() builtin isn't supported yet on WebAssembly and Windows. t.Run("recover.go", func(t *testing.T) { t.Parallel() |