Skip to content

Commit 316d22c

Browse files
authored
Merge pull request #166 from bytecodealliance/ydnar/test-module
tests: add standalone tests module for testing generated Go code
2 parents a50b64c + 3882c47 commit 316d22c

File tree

104 files changed

+7937
-5
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7937
-5
lines changed

.github/dependabot.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,9 @@ updates:
1111
schedule:
1212
interval: weekly
1313
open-pull-requests-limit: 10
14+
15+
- package-ecosystem: gomod
16+
directory: "/tests"
17+
schedule:
18+
interval: weekly
19+
open-pull-requests-limit: 10

.github/workflows/test.yaml

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ on:
77
pull_request:
88

99
env:
10-
wasm-tools-version: "1.218.0"
11-
wasmtime-version: "25.0.1"
10+
wasm-tools-version: "1.219.1"
11+
wasmtime-version: "26.0.0"
1212

1313
jobs:
1414
# Vet Go code
@@ -148,6 +148,12 @@ jobs:
148148
- name: Add Go wasm exec to $PATH
149149
run: echo "$(go env GOROOT)/misc/wasm" >> $GITHUB_PATH
150150

151+
- name: Regenerate Go
152+
run: make tests/generated
153+
154+
- name: Verify repo is unchanged
155+
run: git diff --exit-code HEAD
156+
151157
- name: Test wasm/wasip1 with Go
152158
env:
153159
GOARCH: wasm
@@ -166,5 +172,9 @@ jobs:
166172
if: ${{ matrix.tinygo-version != '0.32.0' }}
167173
run: tinygo test -v -target=wasip2 ./...
168174

175+
- name: Test generated Go with TinyGo >= 0.34.0
176+
if: ${{ matrix.tinygo-version != '0.32.0' && matrix.tinygo-version != '0.33.0' }}
177+
run: tinygo test -v -target wasip2 ./tests/...
178+
169179
- name: Verify repo is unchanged
170180
run: git diff --exit-code HEAD

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
.DS_Store
2-
generated
2+
/generated

Makefile

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,27 @@ $(wit_files):
1313
golden: json
1414
go test ./wit -update
1515

16-
# generated writes test Go code to the filesystem
16+
# generated generated writes test Go code to the filesystem
1717
.PHONY: generated
18-
generated: clean
18+
generated: clean json
1919
go test ./wit/bindgen -write
2020

2121
.PHONY: clean
2222
clean:
2323
rm -rf ./generated/*
24+
25+
# tests/generated writes generated Go code to the tests directory
26+
.PHONY: tests/generated
27+
tests/generated: json
28+
go generate ./tests
29+
30+
# test runs Go and TinyGo tests
31+
GOTESTARGS :=
32+
.PHONY: test
33+
test:
34+
go test $(GOTESTARGS) ./...
35+
GOARCH=wasm GOOS=wasip1 go test $(GOTESTARGS) ./...
36+
tinygo test $(GOTESTARGS) ./...
37+
tinygo test -target=wasip1 $(GOTESTARGS) ./...
38+
tinygo test -target=wasip2 $(GOTESTARGS) ./...
39+
tinygo test -target=wasip2 $(GOTESTARGS) ./tests/...

go.work

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
go 1.22.0
2+
3+
use (
4+
.
5+
./tests
6+
)

go.work.sum

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
2+
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
3+
github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw=
4+
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
5+
github.com/spf13/cobra v1.8.1/go.mod h1:wHxEcudfqmLYa8iTfL+OuZPbBZkmvliBWKIezN3kD9Y=
6+
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
7+
github.com/stretchr/objx v0.5.2/go.mod h1:FRsXN1f5AsAjCGJKqEizvkpNtU+EGNCLh3NxZ/8L+MA=
8+
github.com/urfave/cli-altsrc/v3 v3.0.0-alpha2/go.mod h1:Q79oyIY/z4jtzIrKEK6MUeWC7/szGr46x4QdOaOAIWc=
9+
github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY=
10+
github.com/yuin/gopher-lua v1.1.1/go.mod h1:GBR0iDaNXjAgGg9zfCvksxSRnQx76gclCIb7kdAd1Pw=
11+
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
12+
golang.org/x/net v0.30.0/go.mod h1:2wGyMJ5iFasEhkwi13ChkO/t1ECNC4X4eBKkVFyYFlU=
13+
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
14+
golang.org/x/telemetry v0.0.0-20240521205824-bda55230c457/go.mod h1:pRgIJT+bRLFKnoM1ldnzKoxTIn14Yxz928LQRYYgIN0=
15+
golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4=

testdata/go.mod

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// This go.mod file exists to prevent the testdata directory from being included in module distribution.
2+
module testdata
3+
4+
go 1.22.0

0 commit comments

Comments
 (0)