From 7ff90d9a9748417e88bfe43e0821ad359eabd2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Tue, 2 May 2023 18:09:11 +0200 Subject: [PATCH] testscript: fix "signal: killed" exec errors on MacOS On `MacOS` there are lots of reports of unexpected failing tests with output similar to this: ``` [signal: killed] FAIL: testscripts/myecho.txt:1: unexpected command failure ``` On CI builds the workaround has been to downgrade to a builder with MacOS <= 11 (e.g. macos-11 on GitHub). In development on a MacBook, this is not an option. This commit works around what seem to be a upstream bug in `os.Link` by adding a small sleep before `TestingM.Run()` to allow the write of the test command symlinks to be ready. See #200 --- testscript/exe.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/testscript/exe.go b/testscript/exe.go index ed6bd98d..1305b06e 100644 --- a/testscript/exe.go +++ b/testscript/exe.go @@ -12,6 +12,7 @@ import ( "path/filepath" "runtime" "strings" + "time" ) // TestingM is implemented by *testing.M. It's defined as an interface @@ -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.