mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/logger/BenchmarkCopy: don't call t.Fatal from a goroutine
staticcheck go linter says: > daemon/logger/copier_test.go:451:2: SA2002: the goroutine calls T.Fatal, which must be called in the same goroutine as the test (staticcheck) What it doesn't say is why. The reason is, t.Fatal() calls t.FailNow(), which is expected to stop test execution right now. It does so by calling runtime.Goexit(), which, unless called from a main goroutine, does not stop test execution. Anyway, long story short, if we don't care much about stopping the test case immediately, we can just replace t.Fatalf() with t.Errorf() which still marks the test case as failed, but won't stop it immediately. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
This commit is contained in:
parent
33c205be4f
commit
7b6201f032
1 changed files with 2 additions and 3 deletions
|
@ -3,7 +3,6 @@ package logger // import "github.com/docker/docker/daemon/logger"
|
|||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -453,9 +452,9 @@ func piped(b *testing.B, iterations int, delay time.Duration, buf []byte) io.Rea
|
|||
time.Sleep(delay)
|
||||
if n, err := w.Write(buf); err != nil || n != len(buf) {
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
b.Error(err)
|
||||
}
|
||||
b.Fatal(fmt.Errorf("short write"))
|
||||
b.Error("short write")
|
||||
}
|
||||
}
|
||||
w.Close()
|
||||
|
|
Loading…
Add table
Reference in a new issue