internal/processtest: set timeout

Updates #2571
This commit is contained in:
Hajime Hoshi 2023-02-18 17:36:03 +09:00
parent 01b97124c8
commit 0e57fc4c5f

View File

@ -18,10 +18,12 @@ package processtest_test
import (
"bytes"
"context"
"os"
"path/filepath"
"strings"
"testing"
"time"
exec "golang.org/x/sys/execabs"
)
@ -43,7 +45,10 @@ func TestPrograms(t *testing.T) {
}
t.Run(n, func(t *testing.T) {
cmd := exec.Command("go", "run", filepath.Join(dir, n))
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
defer cancel()
cmd := exec.CommandContext(ctx, "go", "run", filepath.Join(dir, n))
stderr := &bytes.Buffer{}
cmd.Stderr = stderr
if err := cmd.Run(); err != nil {