Skip to content

Commit

Permalink
testscript: fix "signal: killed" exec errors on darwin
Browse files Browse the repository at this point in the history
By adding a small sleep before `TestingM.Run()` to allow the write of the test commands to be flushed to disk.

Fixes rogpeppe#200
  • Loading branch information
bep committed May 2, 2023
1 parent 22b9127 commit 5bad37a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions testscript/exe.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"path/filepath"
"runtime"
"strings"
"time"
)

// TestingM is implemented by *testing.M. It's defined as an interface
Expand Down Expand Up @@ -97,6 +98,13 @@ func RunMain(m TestingM, commands map[string]func() int) (exitCode int) {
ts.cmdExec(neg, append([]string{name}, args...))
}
}

if runtime.GOOS == "darwin" {
// Make sure all of the io operations above gets some time to complete.
// See issue #200.
time.Sleep(200 * time.Millisecond)
}

return m.Run()
}
// The command being registered is being invoked, so run it, then exit.
Expand Down

0 comments on commit 5bad37a

Please sign in to comment.