mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/processtest: bug fix: timeout didn't work for go-run
Apparently timing-out for a go-run process didn't work well. Instead, use CommandContext for the actual test binary which is already built.
This commit is contained in:
parent
09d2459f1c
commit
4e7db88829
@ -59,6 +59,11 @@ func TestPrograms(t *testing.T) {
|
||||
// Run sub-tests one by one, not in parallel (#2571).
|
||||
var m sync.Mutex
|
||||
|
||||
tmpdir, err := os.MkdirTemp("", "ebitengine-processtest-*")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
for _, e := range ents {
|
||||
if e.IsDir() {
|
||||
continue
|
||||
@ -72,10 +77,15 @@ func TestPrograms(t *testing.T) {
|
||||
m.Lock()
|
||||
defer m.Unlock()
|
||||
|
||||
bin := filepath.Join(tmpdir, n)
|
||||
if err := exec.Command("go", "build", "-o", bin, filepath.Join(dir, n)).Run(); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), time.Minute)
|
||||
defer cancel()
|
||||
|
||||
cmd := exec.CommandContext(ctx, "go", "run", filepath.Join(dir, n))
|
||||
cmd := exec.CommandContext(ctx, bin)
|
||||
stderr := &bytes.Buffer{}
|
||||
cmd.Stderr = stderr
|
||||
if err := cmd.Run(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user