diff options
Diffstat (limited to 'compiler/compiler_test.go')
-rw-r--r-- | compiler/compiler_test.go | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/compiler/compiler_test.go b/compiler/compiler_test.go index 6db5ebb38..0fb9fa913 100644 --- a/compiler/compiler_test.go +++ b/compiler/compiler_test.go @@ -9,6 +9,7 @@ import ( "testing" "github.com/tinygo-org/tinygo/compileopts" + "github.com/tinygo-org/tinygo/goenv" "github.com/tinygo-org/tinygo/loader" "tinygo.org/x/go-llvm" ) @@ -16,6 +17,11 @@ import ( // Pass -update to go test to update the output of the test files. var flagUpdate = flag.Bool("update", false, "update tests based on test output") +type testCase struct { + file string + target string +} + // Basic tests for the compiler. Build some Go files and compare the output with // the expected LLVM IR for regression testing. func TestCompiler(t *testing.T) { @@ -34,10 +40,7 @@ func TestCompiler(t *testing.T) { t.Skip("compiler tests require LLVM 11 or above, got LLVM ", llvm.Version) } - tests := []struct { - file string - target string - }{ + tests := []testCase{ {"basic.go", ""}, {"pointer.go", ""}, {"slice.go", ""}, @@ -52,6 +55,14 @@ func TestCompiler(t *testing.T) { {"intrinsics.go", "wasm"}, } + _, minor, err := goenv.GetGorootVersion(goenv.Get("GOROOT")) + if err != nil { + t.Fatal("could not read Go version:", err) + } + if minor >= 17 { + tests = append(tests, testCase{"go1.17.go", ""}) + } + for _, tc := range tests { name := tc.file targetString := "wasm" |