...
1# Note: Some tests might fail if Go has been installed with homebrew because
2# the file system layout is different than what the tests expect.
3# Easiest fix is to install without using brew.
4goroot?=$(shell go env GOROOT)
5# Note: The standard binary zig distribution does not ship some testdata.
6# You should override with the zig source code path, otherwise some tests will fail.
7zigroot?=$(shell dirname $(shell which zig))
8
9zig_bin=$(shell pwd)/testdata/zig
10tinygo_bin=$(shell pwd)/testdata/tinygo
11gowasip1_bin=$(shell pwd)/testdata/go
12
13
14# embed/internal/embedtest deals with some paths that are not available here, ignore.
15tinygo_tests=container/heap \
16 container/list \
17 container/ring \
18 crypto/des \
19 crypto/md5 \
20 crypto/rc4 \
21 crypto/sha1 \
22 crypto/sha256 \
23 crypto/sha512 \
24 encoding \
25 encoding/ascii85 \
26 encoding/base32 \
27 encoding/csv \
28 encoding/hex \
29 go/scanner \
30 hash \
31 hash/adler32 \
32 hash/crc64 \
33 hash/fnv \
34 html \
35 internal/itoa \
36 internal/profile \
37 math \
38 math/cmplx \
39 net \
40 net/http/internal/ascii \
41 net/mail \
42 os \
43 path \
44 reflect \
45 sync \
46 testing \
47 testing/iotest \
48 text/scanner \
49 unicode \
50 unicode/utf16 \
51 unicode/utf8
52
53gowasip1_tests=src/archive/tar \
54 src/bufio \
55 src/bytes \
56 src/context \
57 src/encoding/ascii85 \
58 src/encoding/asn1 \
59 src/encoding/base32 \
60 src/encoding/base64 \
61 src/encoding/binary \
62 src/encoding/csv \
63 src/encoding/gob \
64 src/encoding/hex \
65 src/encoding/json \
66 src/encoding/pem \
67 src/encoding/xml \
68 src/errors \
69 src/expvar \
70 src/flag \
71 src/fmt \
72 src/hash \
73 src/hash/adler32 \
74 src/hash/crc32 \
75 src/hash/crc64 \
76 src/hash/fnv \
77 src/hash/maphash \
78 src/io \
79 src/io/fs \
80 src/io/ioutil \
81 src/log \
82 src/log/syslog \
83 src/maps \
84 src/math \
85 src/math/big \
86 src/math/bits \
87 src/math/cmplx \
88 src/math/rand \
89 src/mime \
90 src/mime/multipart \
91 src/mime/quotedprintable \
92 src/os \
93 src/os/exec \
94 src/os/signal \
95 src/os/user \
96 src/path \
97 src/reflect \
98 src/regexp \
99 src/regexp/syntax \
100 src/runtime \
101 src/runtime/internal/atomic \
102 src/runtime/internal/math \
103 src/runtime/internal/sys \
104 src/slices \
105 src/sort \
106 src/strconv \
107 src/strings \
108 src/sync \
109 src/sync/atomic \
110 src/syscall \
111 src/testing \
112 src/testing/fstest \
113 src/testing/iotest \
114 src/testing/quick \
115 src/time
116
117all: build.zig build.tinygo build.gowasip1
118
119run:
120 go test -bench=. -benchtime=1x
121
122
123.PHONY: build.zig
124build.zig:
125 # --test-no-exec allows building of the test Wasm binary without executing command.
126 # We use find because the test.wasm will be something like ./zig-cache/o/dd6df1361b2134adc5eee9d027495436/test.wasm
127 @mkdir -p $(zig_bin)
128 @cd $(zigroot) && zig test --test-no-exec -target wasm32-wasi --zig-lib-dir $(zigroot)/lib $(zigroot)/lib/std/std.zig
129 @cp $$(find $(zigroot) -name test.wasm) $(zig_bin)/test.wasm
130 # The generated test binary is large and produces skewed results in favor of the optimized compiler.
131 # We also generate a stripped, optimized binary with wasm-opt.
132 @wasm-opt $(zig_bin)/test.wasm -O --strip-dwarf -o $(zig_bin)/test-opt.wasm
133
134.PHONY: build.tinygo
135build.tinygo:
136 @mkdir -p $(tinygo_bin)
137 for value in $(tinygo_tests); do\
138 echo Building $${value}... ;\
139 tinygo test -target wasi -c -o $(tinygo_bin)/$$(echo $$value | sed -e 's/\//_/g').test $${value} 2>&1 >/dev/null ;\
140 done
141
142.PHONY: build.gowasip1
143build.gowasip1:
144 @mkdir -p $(gowasip1_bin)
145 @cd '$(goroot)'; \
146 for value in $(gowasip1_tests); do\
147 GOOS=wasip1 GOARCH=wasm go test -v -c -o $(gowasip1_bin)/$$(echo $$value | sed -e 's/\//_/g').test ./$${value}; \
148 done
View as plain text