diff --git a/assets/web/html.zip b/assets/web/html.zip index 7cc3e8f..2ddb579 100644 Binary files a/assets/web/html.zip and b/assets/web/html.zip differ diff --git a/tests/e2e/run_binary_test.go b/tests/e2e/run_binary_test.go index 34a7b02..d41cfc0 100644 --- a/tests/e2e/run_binary_test.go +++ b/tests/e2e/run_binary_test.go @@ -27,7 +27,7 @@ func TestRunBinary(t *testing.T) { c.Start() defer c.Stop() - WaitForRunningOrFail(t, c) + WaitForRunningOrFail(t, c, true) assert.True(t, LogContainsText(c.Status(), "listening on localhost:12345") || LogContainsText(c.Status(), "listening on 127.0.0.1:12345"), WhatsWrong(c.Status())) diff --git a/tests/framework/util.go b/tests/framework/util.go index e9ee8b2..c6b4c6f 100644 --- a/tests/framework/util.go +++ b/tests/framework/util.go @@ -46,7 +46,7 @@ func FindBinary(t *testing.T) (string, error) { } func IsRunning(s cmd.Status) bool { - return s.Error == nil && s.StartTs > 0 && !s.Complete && s.Exit == 0 + return s.Error == nil && s.StartTs > 0 && !s.Complete && s.Exit == -1 } func LogContainsText(s cmd.Status, text string) bool { @@ -75,17 +75,30 @@ func WhatsWrong(s cmd.Status) error { return errors.New("debug info: " + string(marshal)) } -func WaitForRunningOrFail(t *testing.T, c *cmd.Cmd) { - timer := time.NewTimer(3 * time.Second) - ticker := time.NewTimer(100 * time.Millisecond) - - select { - case <-timer.C: - t.Fatalf("failed to start: %v", WhatsWrong(c.Status())) - case <-ticker.C: - status := c.Status() - if IsRunning(status) { - break +// WaitForRunningOrFail checks if stdout or stderr has content when mustWaitForStdOutput is true. +// mustWaitForStdOutput is useful when the OS performs security checks on the binary, which can be +// terribly slow on macOS. +func WaitForRunningOrFail(t *testing.T, c *cmd.Cmd, mustWaitForStdOutput bool) { + timer := time.NewTimer(100 * time.Second) + ticker := time.NewTicker(100 * time.Millisecond) + defer timer.Stop() + defer ticker.Stop() + + for { + select { + case <-timer.C: + t.Fatalf("failed to start: %v", WhatsWrong(c.Status())) + case <-ticker.C: + status := c.Status() + if IsRunning(status) { + if mustWaitForStdOutput { + if len(status.Stdout) > 0 || len(status.Stderr) > 0 { + return + } + } else { + return + } + } } }