Fix nondeterministic behavior (#9341)

The underlying implementation of os.exec uses channels and goroutines.
It is possible to have time-variant error values returned from Cmd.Wait
depending on which comes first.

Also, the git subcommand and options should be separated tokens.

Fixes a flaky test in modules/git/command_test.go
This commit is contained in:
Mura Li 2019-12-13 17:03:38 +08:00 committed by Lunny Xiao
parent 39db99a595
commit 6e6936d73d
2 changed files with 2 additions and 2 deletions

View file

@ -138,7 +138,7 @@ func (c *Command) RunInDirTimeoutEnvFullPipelineFunc(env []string, timeout time.
fn(ctx, cancel)
}
if err := cmd.Wait(); err != nil {
if err := cmd.Wait(); err != nil && ctx.Err() != context.DeadlineExceeded {
return err
}