Skip to content

Commit bbf835f

Browse files
committed
build: almost complete module support
This is a necessarily large PR to offer almost complete Go modules support for GopherJS. * We now use github.com/rogpeppe/go-internal to be able to write testscript tests * A suite of testscript tests have been added to cover the major GopherJS commands operating in both GOPATH mode and module mode * The GopherJS tool and build packages have been heavily refactored in places to support Go modules. GopherJS support for Go modules follows the same patterns as the go tool. * We fix the build cache to be a function of the augmented packages as opposed (incorrectly) to the unaugmented package files. This has a slight cost because of the way the augmentation code is currently written (this could be refactored in a later PR) because every file is unconditionally parsed. Main and test packages are not cached (again, we could change this in a later PR). Because it would just work. * We fix the tests/run.go wrapper around the fixedbugs tests in the Go distribution to not perform a chdir into GOROOT; this does not work with modules. * We tidy up .circleci/config.yml to split commands into their separate run sections where it makes sense to. * We add genmodstubbs.go to automatically populate the stubs we need in testdata/mod for the loading of github.com/gopherjs/gopherjs/{js,nosync}.
1 parent 167388b commit bbf835f

37 files changed

+2543
-487
lines changed

.circleci/config.yml

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -70,47 +70,17 @@ jobs:
7070
7171
# this gives us the repo-local binaries we require
7272
npm install
73-
74-
- run: |
75-
go install github.com/gopherjs/gopherjs
76-
77-
- run:
78-
# because this is a long-running test suite
79-
no_output_timeout: 30m
80-
command: |
81-
82-
echo ">> Regenerate compiler/prelude"
83-
go generate github.com/gopherjs/gopherjs/compiler/prelude
84-
85-
echo ">> Ensure we have a tidy go.{mod,sum}"
86-
go mod tidy
87-
go list all > /dev/null # https://github.com/golang/go/issues/27868#issuecomment-431413621
88-
89-
git diff
90-
91-
echo ">> Ensure there are no variations from the git commit"
92-
diff -u <(echo -n) <(git status --porcelain)
93-
94-
echo ">> Ensure all go code is well formatted."
95-
diff -u <(echo -n) <(gofmt -d .)
96-
97-
echo ">> Vetting github.com/gopherjs/gopherjs"
98-
go vet .
99-
100-
echo ">> vet all packages except tests"
101-
go vet $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests)
102-
103-
echo ">> All those packages should have // +build js."
104-
diff -u <(echo "github.com/gopherjs/gopherjs/compiler/natives") <(go list ./compiler/natives/...)
105-
106-
echo ">> Should build successfully (can't run tests, since only client is supported)."
107-
gopherjs install -v net/http
108-
109-
echo ">> Run the core gopherjs tests; exclusions take from .std_test_pkg_exclusions."
110-
gopherjs test --minify -v --short github.com/gopherjs/gopherjs/tests/... $(go list std | grep -v -x -f .std_test_pkg_exclusions)
111-
112-
echo ">> Race tests."
113-
go test -v -race ./...
114-
115-
echo ">> Non-minified gopherjs tests should also work."
116-
gopherjs test -v fmt
73+
- run: go install github.com/gopherjs/gopherjs
74+
- run: go generate github.com/gopherjs/gopherjs/compiler/prelude
75+
- run: go mod tidy && go list all > /dev/null # https://github.com/golang/go/issues/27868#issuecomment-431413621
76+
- run: go run genmodstubs.go
77+
- run: git diff
78+
- run: diff -u <(echo -n) <(git status --porcelain)
79+
- run: diff -u <(echo -n) <(gofmt -d .)
80+
- run: go vet .
81+
- run: go vet $(go list ./... | grep -v github.com/gopherjs/gopherjs/tests)
82+
- run: diff -u <(echo "github.com/gopherjs/gopherjs/compiler/natives") <(go list ./compiler/natives/...)
83+
- run: gopherjs install -v net/http
84+
- run: gopherjs test --minify -v --short github.com/gopherjs/gopherjs/tests/... $(go list std | grep -v -x -f .std_test_pkg_exclusions)
85+
- run: go test -v ./...
86+
- run: gopherjs test -v fmt

0 commit comments

Comments
 (0)