Skip to content

Commit 0606312

Browse files
committed
ci: parallelise the running of gopherjs tests
Currently we run the gopherjs tests in sequence; this is limited to a single CPU core because we ultimately run the tests via Node. We can improve on this by concurrently running gopherjs test per package. Also implemented a fix discussed in a previous issue/PR to make our list of package exclusions explicit, via std_test_pkg_exclusions
1 parent e14987c commit 0606312

File tree

3 files changed

+212
-111
lines changed

3 files changed

+212
-111
lines changed

circle.yml

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ machine:
77
dependencies:
88
pre:
99
- cd /usr/local && sudo rm -rf go && curl https://storage.googleapis.com/golang/go1.10.linux-amd64.tar.gz | sudo tar -xz && sudo chmod a+w go/src/path/filepath
10+
- go get myitcv.io/cmd/concsh
11+
- which concsh
12+
- nproc --all
1013
post:
1114
- mv ./gopherjs $HOME/bin
1215
- npm install --global node-gyp
@@ -19,116 +22,6 @@ test:
1922
- for d in */; do echo $d; done | grep -v tests/ | grep -v third_party/ | xargs go tool vet # All subdirectories except "tests", "third_party".
2023
- diff -u <(echo -n) <(go list ./compiler/natives/src/...) # All those packages should have // +build js.
2124
- gopherjs install -v net/http # Should build successfully (can't run tests, since only client is supported).
22-
- >
23-
ulimit -s 10000 && gopherjs test --minify -v --short
24-
github.com/gopherjs/gopherjs/tests
25-
github.com/gopherjs/gopherjs/tests/main
26-
github.com/gopherjs/gopherjs/js
27-
archive/tar
28-
archive/zip
29-
bufio
30-
bytes
31-
compress/bzip2
32-
compress/flate
33-
compress/gzip
34-
compress/lzw
35-
compress/zlib
36-
container/heap
37-
container/list
38-
container/ring
39-
crypto/aes
40-
crypto/cipher
41-
crypto/des
42-
crypto/dsa
43-
crypto/ecdsa
44-
crypto/elliptic
45-
crypto/hmac
46-
crypto/md5
47-
crypto/rand
48-
crypto/rc4
49-
crypto/rsa
50-
crypto/sha1
51-
crypto/sha256
52-
crypto/sha512
53-
crypto/subtle
54-
crypto/x509
55-
database/sql
56-
database/sql/driver
57-
debug/dwarf
58-
debug/elf
59-
debug/macho
60-
debug/pe
61-
encoding/ascii85
62-
encoding/asn1
63-
encoding/base32
64-
encoding/base64
65-
encoding/binary
66-
encoding/csv
67-
encoding/gob
68-
encoding/hex
69-
encoding/json
70-
encoding/pem
71-
encoding/xml
72-
errors
73-
expvar
74-
flag
75-
fmt
76-
go/ast
77-
go/constant
78-
go/doc
79-
go/format
80-
go/parser
81-
go/printer
82-
go/scanner
83-
go/token
84-
hash/adler32
85-
hash/crc32
86-
hash/crc64
87-
hash/fnv
88-
html
89-
html/template
90-
image
91-
image/color
92-
image/draw
93-
image/gif
94-
image/jpeg
95-
image/png
96-
index/suffixarray
97-
io
98-
io/ioutil
99-
math
100-
math/big
101-
math/bits
102-
math/cmplx
103-
math/rand
104-
mime
105-
mime/multipart
106-
mime/quotedprintable
107-
net/http/cookiejar
108-
net/http/fcgi
109-
net/mail
110-
net/rpc/jsonrpc
111-
net/textproto
112-
net/url
113-
os/user
114-
path
115-
path/filepath
116-
reflect
117-
regexp
118-
regexp/syntax
119-
sort
120-
strconv
121-
strings
122-
sync
123-
sync/atomic
124-
testing/quick
125-
text/scanner
126-
text/tabwriter
127-
text/template
128-
text/template/parse
129-
time
130-
unicode
131-
unicode/utf16
132-
unicode/utf8
25+
- go run run_tests.go -debug
13326
- go test -v -race ./...
13427
- gopherjs test -v fmt # No minification should work.

run_tests.go

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
// +build ignore
2+
3+
package main
4+
5+
import (
6+
"bufio"
7+
"flag"
8+
"fmt"
9+
"go/build"
10+
"os"
11+
"os/exec"
12+
"path/filepath"
13+
"runtime"
14+
"strings"
15+
)
16+
17+
const (
18+
ciParallelism = 2
19+
self = "github.com/gopherjs/gopherjs"
20+
)
21+
22+
var (
23+
fDebug = flag.Bool("debug", false, "include debug output")
24+
)
25+
26+
func main() {
27+
flag.Parse()
28+
29+
if err := run(); err != nil {
30+
fmt.Fprintf(os.Stderr, "Failed to run tests: %v\n", err)
31+
os.Exit(1)
32+
}
33+
}
34+
35+
func run() error {
36+
37+
bpkg, err := build.Import(self, ".", build.FindOnly)
38+
if err != nil {
39+
return fmt.Errorf("failed to get directory for import %v: %v", self, err)
40+
}
41+
42+
exPath := filepath.Join(bpkg.Dir, "std_test_pkg_exclusions")
43+
44+
exFi, err := os.Open(exPath)
45+
if err != nil {
46+
return fmt.Errorf("error opening %v: %v", exPath, err)
47+
}
48+
49+
excls := make(map[string]bool)
50+
51+
{
52+
sc := bufio.NewScanner(exFi)
53+
for sc.Scan() {
54+
line := strings.TrimSpace(sc.Text())
55+
56+
if strings.HasPrefix(line, "#") {
57+
continue
58+
}
59+
60+
excls[line] = true
61+
}
62+
if err := sc.Err(); err != nil {
63+
return fmt.Errorf("failed to line scan %v: %v", exPath, err)
64+
}
65+
}
66+
67+
cmd := exec.Command("go", "list", "std")
68+
stdListOut, err := cmd.Output()
69+
if err != nil {
70+
return fmt.Errorf("failed to %v: %v", strings.Join(cmd.Args, " "), err)
71+
}
72+
73+
tests := []string{
74+
"github.com/gopherjs/gopherjs/tests",
75+
"github.com/gopherjs/gopherjs/tests/main",
76+
"github.com/gopherjs/gopherjs/js",
77+
}
78+
79+
{
80+
sc := bufio.NewScanner(strings.NewReader(string(stdListOut)))
81+
for sc.Scan() {
82+
line := strings.TrimSpace(sc.Text())
83+
84+
if strings.HasPrefix(line, "#") {
85+
continue
86+
}
87+
88+
if !excls[line] {
89+
tests = append(tests, line)
90+
}
91+
}
92+
if err := sc.Err(); err != nil {
93+
return fmt.Errorf("failed to line scan %q: %v", strings.Join(cmd.Args, " "), err)
94+
}
95+
}
96+
97+
var cmds []string
98+
99+
for _, t := range tests {
100+
cmds = append(cmds, fmt.Sprintf("gopherjs test -m %v\n", t))
101+
}
102+
103+
p := runtime.NumCPU()
104+
105+
if v, ok := os.LookupEnv("CI"); ok && v == "TRUE" {
106+
// because Circle doesn't seem very happy when we flood it with work
107+
p = ciParallelism
108+
}
109+
110+
debugf("running tests with parallelism %v\n", p)
111+
112+
testCmd := exec.Command("concsh", "-conc", fmt.Sprintf("%v", p))
113+
testCmd.Stdin = strings.NewReader(strings.Join(cmds, ""))
114+
testCmd.Stdout = os.Stdout
115+
testCmd.Stderr = os.Stderr
116+
117+
if err := testCmd.Run(); err != nil {
118+
return fmt.Errorf("test process exited with an error: %v", err)
119+
}
120+
121+
return nil
122+
}
123+
124+
func debugf(format string, args ...interface{}) {
125+
if *fDebug {
126+
fmt.Fprintf(os.Stderr, format, args...)
127+
}
128+
}

std_test_pkg_exclusions

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# these are go list std packages we want to exclude from our tests
2+
context
3+
crypto
4+
crypto/internal/cipherhw
5+
crypto/tls
6+
crypto/x509/pkix
7+
debug/gosym
8+
debug/plan9obj
9+
encoding
10+
go/build
11+
go/importer
12+
go/internal/gccgoimporter
13+
go/internal/gcimporter
14+
go/internal/srcimporter
15+
go/types
16+
hash
17+
image/color/palette
18+
image/internal/imageutil
19+
internal/cpu
20+
internal/nettrace
21+
internal/poll
22+
internal/race
23+
internal/singleflight
24+
internal/syscall/unix
25+
internal/syscall/windows
26+
internal/syscall/windows/registry
27+
internal/syscall/windows/sysdll
28+
internal/testenv
29+
internal/testlog
30+
internal/trace
31+
log
32+
log/syslog
33+
net
34+
net/http
35+
net/http/cgi
36+
net/http/httptest
37+
net/http/httptrace
38+
net/http/httputil
39+
net/http/internal
40+
net/http/pprof
41+
net/internal/socktest
42+
net/rpc
43+
net/smtp
44+
os
45+
os/exec
46+
os/signal
47+
os/signal/internal/pty
48+
plugin
49+
runtime
50+
runtime/cgo
51+
runtime/debug
52+
runtime/internal/atomic
53+
runtime/internal/sys
54+
runtime/pprof
55+
runtime/pprof/internal/profile
56+
runtime/race
57+
runtime/trace
58+
syscall
59+
testing
60+
testing/internal/testdeps
61+
testing/iotest
62+
unsafe
63+
vendor/golang_org/x/crypto/chacha20poly1305
64+
vendor/golang_org/x/crypto/chacha20poly1305/internal/chacha20
65+
vendor/golang_org/x/crypto/cryptobyte
66+
vendor/golang_org/x/crypto/cryptobyte/asn1
67+
vendor/golang_org/x/crypto/curve25519
68+
vendor/golang_org/x/crypto/poly1305
69+
vendor/golang_org/x/net/http2/hpack
70+
vendor/golang_org/x/net/idna
71+
vendor/golang_org/x/net/internal/nettest
72+
vendor/golang_org/x/net/lex/httplex
73+
vendor/golang_org/x/net/nettest
74+
vendor/golang_org/x/net/proxy
75+
vendor/golang_org/x/text/secure
76+
vendor/golang_org/x/text/secure/bidirule
77+
vendor/golang_org/x/text/transform
78+
vendor/golang_org/x/text/unicode
79+
vendor/golang_org/x/text/unicode/bidi
80+
vendor/golang_org/x/text/unicode/norm

0 commit comments

Comments
 (0)