Skip to content

Commit 7b8ece4

Browse files
committed
test: fix race condition
1 parent cdf8d87 commit 7b8ece4

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

command.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ func (c *Command) RunInDirPipelineWithTimeout(timeout time.Duration, stdout, std
135135

136136
select {
137137
case <-ctx.Done():
138+
<-result
138139
if cmd.Process != nil && cmd.ProcessState != nil && !cmd.ProcessState.Exited() {
139140
if err := cmd.Process.Kill(); err != nil {
140141
return fmt.Errorf("kill process: %v", err)
141142
}
142143
}
143144

144-
<-result
145145
return ErrExecTimeout
146146
case err = <-result:
147147
return err

git_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ func TestSetPrefix(t *testing.T) {
5757
}
5858

5959
func Test_log(t *testing.T) {
60+
old := logOutput
61+
defer SetOutput(old)
62+
6063
tests := []struct {
6164
format string
6265
args []interface{}

0 commit comments

Comments
 (0)