зеркало из https://github.com/go-gitea/git.git
Rectify error handling (#44)
* Rectify error handling * Log the error returned by exec.Wait
This commit is contained in:
Родитель
f0a094c4f9
Коммит
4c374b37db
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче