diff --git a/command.go b/command.go index c3534a145..145480e58 100644 --- a/command.go +++ b/command.go @@ -70,7 +70,11 @@ func (c *Command) RunInDirTimeoutPipeline(timeout time.Duration, dir string, std return err } - return cmd.Wait() + if err := cmd.Wait(); err != nil { + log("exec.Wait: %v", err) + } + + return ctx.Err() } // RunInDirTimeout executes the command in given directory with given timeout, diff --git a/command_test.go b/command_test.go index a01aa042d..2f35b3c32 100644 --- a/command_test.go +++ b/command_test.go @@ -7,6 +7,7 @@ package git import ( + "context" "testing" "time" ) @@ -32,10 +33,7 @@ func TestRunInDirTimeoutPipelineAlwaysTimeout(t *testing.T) { cmd := NewCommand("hash-object --stdin") for i := 0; i < maxLoops; i++ { if err := cmd.RunInDirTimeoutPipeline(1*time.Microsecond, "", nil, nil); err != nil { - // 'context deadline exceeded' when the error is returned by exec.Start - // 'signal: killed' when the error is returned by exec.Wait - // It depends on the point of the time (before or after exec.Start returns) at which the timeout is triggered. - if err.Error() != "context deadline exceeded" && err.Error() != "signal: killed" { + if err != context.DeadlineExceeded { t.Fatalf("Testing %d/%d: %v", i, maxLoops, err) } }