run tests partially in parallel
Этот коммит содержится в:
родитель
ec2658ca79
коммит
525ded3d90
1 изменённых файлов: 18 добавлений и 1 удалений
19
main_test.go
19
main_test.go
|
@ -12,6 +12,7 @@ import (
|
|||
"path/filepath"
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
"github.com/tinygo-org/tinygo/compileopts"
|
||||
|
@ -67,6 +68,8 @@ func TestCompiler(t *testing.T) {
|
|||
}
|
||||
|
||||
func runPlatTests(target string, matches []string, t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
for _, path := range matches {
|
||||
switch {
|
||||
case target == "wasm":
|
||||
|
@ -86,11 +89,25 @@ func runPlatTests(target string, matches []string, t *testing.T) {
|
|||
}
|
||||
|
||||
t.Run(filepath.Base(path), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
runTest(path, target, t)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// Due to some problems with LLD, we cannot run links in parallel, or in parallel with compiles.
|
||||
// Therefore, we put a lock around builds and run everything else in parallel.
|
||||
var buildLock sync.Mutex
|
||||
|
||||
// runBuild is a thread-safe wrapper around Build.
|
||||
func runBuild(src, out string, opts *compileopts.Options) error {
|
||||
buildLock.Lock()
|
||||
defer buildLock.Unlock()
|
||||
|
||||
return Build(src, out, opts)
|
||||
}
|
||||
|
||||
func runTest(path, target string, t *testing.T) {
|
||||
// Get the expected output for this test.
|
||||
txtpath := path[:len(path)-3] + ".txt"
|
||||
|
@ -130,7 +147,7 @@ func runTest(path, target string, t *testing.T) {
|
|||
WasmAbi: "js",
|
||||
}
|
||||
binary := filepath.Join(tmpdir, "test")
|
||||
err = Build("./"+path, binary, config)
|
||||
err = runBuild("./"+path, binary, config)
|
||||
if err != nil {
|
||||
if errLoader, ok := err.(loader.Errors); ok {
|
||||
for _, err := range errLoader.Errs {
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче