internal/processtest: use a semaphore for sub-tests

Updates #2571
This commit is contained in:
Hajime Hoshi 2023-02-25 16:18:13 +09:00
parent aca42e4046
commit ff1621885d

View File

@ -22,6 +22,7 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
"sync"
"testing" "testing"
"time" "time"
@ -35,6 +36,9 @@ func TestPrograms(t *testing.T) {
t.Fatal(err) t.Fatal(err)
} }
// Run sub-tests one by one, not in parallel (#2571).
var m sync.Mutex
for _, e := range ents { for _, e := range ents {
if e.IsDir() { if e.IsDir() {
continue continue
@ -45,6 +49,9 @@ func TestPrograms(t *testing.T) {
} }
t.Run(n, func(t *testing.T) { t.Run(n, func(t *testing.T) {
m.Lock()
defer m.Unlock()
ctx, cancel := context.WithTimeout(context.Background(), time.Minute) ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel() defer cancel()