Skip to content

Commit

Permalink
Upgrade tinylib for test
Browse files Browse the repository at this point in the history
Fix tinylib tests on windows
Fix windows lint
  • Loading branch information
klauspost committed Oct 27, 2023
1 parent c902840 commit 4124256
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ ci: prepare
if [ `arch` == 'x86_64' ]; then \
sudo apt-get -y -q update; \
sudo apt-get -y -q install build-essential; \
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.26.0/tinygo_0.26.0_amd64.deb; \
sudo dpkg -i tinygo_0.26.0_amd64.deb; \
wget -q https://github.com/tinygo-org/tinygo/releases/download/v0.30.0/tinygo_0.30.0_amd64.deb; \
sudo dpkg -i tinygo_0.30.0_amd64.deb; \
export PATH=$$PATH:/usr/local/tinygo/bin; \
fi
go test -v ./... ./_generated
4 changes: 2 additions & 2 deletions msgp/advise_other.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//go:build (!linux && !tinygo) || appengine
// +build !linux,!tinygo appengine
//go:build (!linux && !tinygo && !windows) || appengine
// +build !linux,!tinygo,!windows appengine

package msgp

Expand Down
22 changes: 18 additions & 4 deletions tinygotest/tinygo_test.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
//go:build (amd64 && go1.18) || (darwin && go1.18)
// +build amd64,go1.18 darwin,go1.18
//go:build amd64 || darwin

package tinygotest

Expand All @@ -12,6 +11,7 @@ import (
"os"
"os/exec"
"path/filepath"
"runtime"
"strings"
"testing"
)
Expand Down Expand Up @@ -148,6 +148,9 @@ var buildOnlyTargets = []string{

func run(t *testing.T, dir, exe string, args ...string) {
t.Helper()
if runtime.GOOS == "windows" {
exe += ".exe"
}
cmd := exec.Command("./" + exe)
wd, err := os.Getwd()
if err != nil {
Expand Down Expand Up @@ -199,15 +202,22 @@ func tinygoBuild(t *testing.T, dir string, targets ...string) {
for _, tgt := range targets {

ext := ".bin"
dst := tgt + ext
if tgt == "wasm" {
ext = ".wasm"
}
if tgt == "" {
dst = "nativebin"
if runtime.GOOS == "windows" {
dst += ".exe"
}
}

var args []string
if tgt == "" { // empty target means the native platform
args = []string{"build", "-o=nativebin", "."}
args = []string{"build", "-o=" + dst, "."}
} else {
args = []string{"build", "-target=" + tgt, "-o=" + tgt + ext, "."}
args = []string{"build", "-target=" + tgt, "-o=" + dst, "."}
}

t.Logf("%s: tinygo %v", dir, args)
Expand All @@ -218,6 +228,10 @@ func tinygoBuild(t *testing.T, dir string, targets ...string) {
t.Logf("%s: tinygo build %v; output: %s", dir, args, b)
}
if err != nil {
// See https://github.com/tinygo-org/tinygo/issues/3977
if strings.Contains(string(b), "could not find wasm-opt") {
t.Skipf("skipping wasm test because wasm-opt is not installed")
}
t.Fatal(err)
}
}
Expand Down

0 comments on commit 4124256

Please sign in to comment.