mirror of
https://github.com/tailscale/tailscale.git
synced 2025-02-21 12:28:39 +00:00
cmd/testwrapper: fix exit deflake (#9342)
Sometimes `go test` would exit and close its stdout before we started reading it, and we would return that "file closed" error then forget to os.Exit(1). Fixed to prefer the go test subprocess error and exit regardless of the type of error. Fixes #9334 Signed-off-by: Paul Scott <paul@tailscale.com>
This commit is contained in:
parent
0396366aae
commit
683ba62f3e
@ -89,11 +89,6 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, otherArgs []st
|
||||
log.Printf("error starting test: %v", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
cmdErr := make(chan error, 1)
|
||||
go func() {
|
||||
defer close(cmdErr)
|
||||
cmdErr <- cmd.Wait()
|
||||
}()
|
||||
|
||||
s := bufio.NewScanner(r)
|
||||
resultMap := make(map[string]map[string]*testAttempt) // pkg -> test -> testAttempt
|
||||
@ -164,10 +159,13 @@ func runTests(ctx context.Context, attempt int, pt *packageTests, otherArgs []st
|
||||
}
|
||||
}
|
||||
}
|
||||
if err := s.Err(); err != nil {
|
||||
if err := cmd.Wait(); err != nil {
|
||||
return err
|
||||
}
|
||||
return <-cmdErr
|
||||
if err := s.Err(); err != nil {
|
||||
return fmt.Errorf("reading go test stdout: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func main() {
|
||||
@ -303,6 +301,8 @@ func main() {
|
||||
os.Exit(exit.ExitCode())
|
||||
}
|
||||
}
|
||||
log.Printf("testwrapper: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
if len(toRetry) == 0 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user