From 9b3eb3fe59fc6443b05dfa8f6d7c4512829cc246 Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Tue, 29 Oct 2024 09:47:14 +0100 Subject: [PATCH] ci: run at least some tests on older Go/LLVM versions These should make sure basic functionality is still working. Using the `-short` flag to avoid taking too long to run all tests (and to install all the necessary emulators), and because some targets might not work in older Go/LLVM versions (such as WASI). This does _not_ run tests and checks against expected IR, because LLVM IR changes a lot across versions. --- .circleci/config.yml | 2 ++ main_test.go | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 826240d9a..ce3417ffb 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -90,6 +90,8 @@ commands: name: Check Go code formatting command: make fmt-check lint - run: make gen-device -j4 + # TODO: change this to -skip='TestErrors|TestWasm' with Go 1.20 + - run: go test -tags=llvm<> -short -run='TestBuild|TestTest|TestGetList|TestTraceback' - run: make smoketest XTENSA=0 - save_cache: key: go-cache-v4-{{ checksum "go.mod" }}-{{ .Environment.CIRCLE_BUILD_NUM }} diff --git a/main_test.go b/main_test.go index ecff13427..22ac549de 100644 --- a/main_test.go +++ b/main_test.go @@ -15,7 +15,6 @@ import ( "reflect" "regexp" "runtime" - "slices" "strings" "sync" "testing" @@ -521,7 +520,7 @@ func TestWebAssembly(t *testing.T) { } } } - if !slices.Equal(imports, tc.imports) { + if !stringSlicesEqual(imports, tc.imports) { t.Errorf("import list not as expected!\nexpected: %v\nactual: %v", tc.imports, imports) } } @@ -529,6 +528,20 @@ func TestWebAssembly(t *testing.T) { } } +func stringSlicesEqual(s1, s2 []string) bool { + // We can use slices.Equal once we drop support for Go 1.20 (it was added in + // Go 1.21). + if len(s1) != len(s2) { + return false + } + for i, s := range s1 { + if s != s2[i] { + return false + } + } + return true +} + func TestWasmExport(t *testing.T) { t.Parallel()