Skip to content

Commit fb8ae00

Browse files
committed
Set up a simple smoke test job on Windows and Mac OS.
Ideally we'd do the complete set of tests, but there is a fair amount of edge cases fixing which would require a significant effort. For now we simply ensure that GopherJS can build, run tests and passes its own tests.
1 parent 8b2fae6 commit fb8ae00

File tree

6 files changed

+367
-113
lines changed

6 files changed

+367
-113
lines changed

build/context_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package build
33
import (
44
"fmt"
55
"go/build"
6-
"path"
76
"path/filepath"
87
"strings"
98
"testing"
@@ -20,6 +19,7 @@ func TestSimpleCtx(t *testing.T) {
2019
gopherjsRoot := filepath.Join(e.GOROOT, "src", "github.com", "gopherjs", "gopherjs")
2120
fs := &withPrefix{gopherjspkg.FS, gopherjsRoot}
2221
ec := embeddedCtx(fs, e)
22+
ec.bctx.JoinPath = filepath.Join // Avoid diffs in the test on Windows.
2323

2424
gc := goCtx(e)
2525

@@ -194,16 +194,16 @@ func TestIsStd(t *testing.T) {
194194
}
195195

196196
func expectedPackage(bctx *build.Context, importPath string, goarch string) *build.Package {
197-
targetRoot := path.Clean(fmt.Sprintf("%s/pkg/%s_%s", bctx.GOROOT, bctx.GOOS, goarch))
197+
targetRoot := filepath.Clean(filepath.Join(bctx.GOROOT, "pkg", bctx.GOOS+"_"+goarch))
198198
return &build.Package{
199-
Dir: path.Join(bctx.GOROOT, "src", importPath),
199+
Dir: filepath.Join(bctx.GOROOT, "src", importPath),
200200
ImportPath: importPath,
201201
Root: bctx.GOROOT,
202-
SrcRoot: path.Join(bctx.GOROOT, "src"),
203-
PkgRoot: path.Join(bctx.GOROOT, "pkg"),
202+
SrcRoot: filepath.Join(bctx.GOROOT, "src"),
203+
PkgRoot: filepath.Join(bctx.GOROOT, "pkg"),
204204
PkgTargetRoot: targetRoot,
205-
BinDir: path.Join(bctx.GOROOT, "bin"),
205+
BinDir: filepath.Join(bctx.GOROOT, "bin"),
206206
Goroot: true,
207-
PkgObj: path.Join(targetRoot, importPath+".a"),
207+
PkgObj: filepath.Join(targetRoot, importPath+".a"),
208208
}
209209
}

circle.yml

Lines changed: 92 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ workflows:
4444
- gorepo_tests:
4545
requires:
4646
- build
47+
- darwin_smoke:
48+
requires:
49+
- build
50+
- windows_smoke:
51+
requires:
52+
- build
4753

4854
parameters:
4955
go_version:
@@ -56,6 +62,11 @@ parameters:
5662
type: string
5763
default: "12"
5864

65+
orbs:
66+
win: circleci/windows@4.0.0
67+
go: circleci/go@1.7.1
68+
node: circleci/node@5.0.1
69+
5970
jobs:
6071
build:
6172
executor: gopherjs
@@ -167,46 +178,98 @@ jobs:
167178
command: |
168179
go test -v github.com/gopherjs/gopherjs/tests/gorepo
169180
181+
windows_smoke:
182+
executor:
183+
name: win/default
184+
shell: powershell.exe
185+
steps:
186+
- checkout
187+
- run:
188+
name: Install Go
189+
command: |
190+
choco install golang --version="<< pipeline.parameters.go_version >>" -my
191+
go version
192+
(Get-Command go).Path
193+
- install_deps:
194+
optional: false
195+
- run:
196+
name: Install GopherJS
197+
command: go install -v .
198+
- run:
199+
name: Test GopherJS
200+
command: go test -v -short ./...
201+
- run:
202+
name: Smoke tests
203+
command: |
204+
$env:NODE_PATH=$(npm root)
205+
$env:SOURCE_MAP_SUPPORT=false
206+
gopherjs build -v net/http
207+
gopherjs test -v --short fmt sort ./tests
208+
209+
darwin_smoke:
210+
macos:
211+
xcode: 13.3.0 # Mac OS 12.2.1
212+
steps:
213+
- checkout
214+
- setup_environment
215+
- install_deps:
216+
optional: false
217+
- run:
218+
name: Install GopherJS
219+
command: go install -v .
220+
- run:
221+
name: Test GopherJS
222+
command: go test -v -short ./...
223+
- run:
224+
name: Smoke tests
225+
command: |
226+
gopherjs build -v net/http
227+
gopherjs test -v --short fmt log os ./tests
228+
170229
commands:
171230
setup_environment:
172231
description: Set up Go, NVM and Node.js
173232
steps:
233+
- go/install:
234+
version: << pipeline.parameters.go_version >>
235+
- node/install:
236+
node-version: << pipeline.parameters.node_version >>
174237
- run:
175-
name: Install Go
238+
name: Set up environment
176239
command: |
177-
cd /usr/local
178-
sudo rm -rf go
179-
curl "https://storage.googleapis.com/golang/go<< pipeline.parameters.go_version >>.linux-amd64.tar.gz" | sudo tar -xz
180-
echo 'export PATH="$PATH:/usr/local/go/bin:$HOME/go/bin"' >> $BASH_ENV
240+
echo 'export PATH="$PATH:$HOME/go/bin"' >> $BASH_ENV
181241
echo 'export GO111MODULE=on' >> $BASH_ENV
182-
. $BASH_ENV
242+
echo 'export SOURCE_MAP_SUPPORT=true' >> $BASH_ENV
243+
# Make nodejs able to require installed modules from any working path.
244+
echo "export NODE_PATH=$(npm root)" >> $BASH_ENV
183245
go version
184-
go get -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports.
185-
- run:
186-
name: Install NVM
187-
command: |
188-
git clone https://github.com/nvm-sh/nvm $HOME/.nvm
189-
cd $HOME/.nvm && git checkout "v<< pipeline.parameters.nvm_version >>"
190-
echo 'export NVM_DIR="${HOME}/.nvm"' >> "${BASH_ENV}"
191-
echo '[ -s "${NVM_DIR}/nvm.sh" ] && \. "${NVM_DIR}/nvm.sh"' >> "${BASH_ENV}"
192-
- run:
193-
name: Install Node.js
194-
command: |
195-
nvm install "<< pipeline.parameters.node_version >>" && nvm alias default "<< pipeline.parameters.node_version >>"
196-
node --version
246+
node -v
247+
go install -v github.com/nevkontakte/go-junit-report@forked # For CircleCI test reports.
197248
install_deps:
198249
description: Install Go and Node dependency packages
250+
parameters:
251+
optional:
252+
default: true
253+
type: boolean
254+
description: Install node-syscall module and its dependencies.
199255
steps:
200-
- run:
201-
name: Install required Node.js packages
202-
command: |
203-
npm ci # Install our dependencies from package.json.
204-
echo 'export SOURCE_MAP_SUPPORT=true' >> $BASH_ENV
205-
# Make nodejs able to require installed modules from any working path.
206-
echo export "NODE_PATH='$(npm root)'" >> "${BASH_ENV}"
207-
- run:
208-
name: Install required Go packages
209-
command: go mod download -x
256+
- when:
257+
condition:
258+
not: << parameters.optional >>
259+
steps:
260+
- run:
261+
name: Install required Node.js packages
262+
command: |
263+
# Extra flags to avoid installing node-syscall.
264+
npm install --no-optional --no-package-lock
265+
- when:
266+
condition: << parameters.optional >>
267+
steps:
268+
- run:
269+
name: Install required Node.js packages (including optional)
270+
command: |
271+
npm ci # Install our dependencies from package.json.
272+
- go/mod-download
210273
install_gopherjs:
211274
description: Install GopherJS
212275
steps:

0 commit comments

Comments
 (0)