mirror of
https://github.com/opencontainers/runc.git
synced 2026-07-11 06:03:57 +08:00
merge branch 'pr-2925'
Akihiro Suda (4): Revert "Makefile: rm go 1.13 workaround" libcontainer: avoid using t.Cleanup go.mod: demote to Go 1.13 CI: enable Go 1.13 again LGTMs: kolyskhin cyphar Closes #2925
This commit is contained in:
@@ -13,6 +13,7 @@ import (
|
||||
|
||||
func TestLoggingToFile(t *testing.T) {
|
||||
l := runLogForwarding(t)
|
||||
defer l.cleanup()
|
||||
|
||||
logToLogWriter(t, l, `{"level": "info","msg":"kitten"}`)
|
||||
finish(t, l)
|
||||
@@ -21,6 +22,7 @@ func TestLoggingToFile(t *testing.T) {
|
||||
|
||||
func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
|
||||
l := runLogForwarding(t)
|
||||
defer l.cleanup()
|
||||
|
||||
logToLogWriter(t, l, "invalid-json-with-kitten")
|
||||
checkWait(t, l, "failed to decode")
|
||||
@@ -34,6 +36,7 @@ func TestLogForwardingDoesNotStopOnJsonDecodeErr(t *testing.T) {
|
||||
|
||||
func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
|
||||
l := runLogForwarding(t)
|
||||
defer l.cleanup()
|
||||
|
||||
logToLogWriter(t, l, `{"level": "alert","msg":"puppy"}`)
|
||||
checkWait(t, l, "failed to parse log level")
|
||||
@@ -47,6 +50,7 @@ func TestLogForwardingDoesNotStopOnLogLevelParsingErr(t *testing.T) {
|
||||
|
||||
func TestLogForwardingStopsAfterClosingTheWriter(t *testing.T) {
|
||||
l := runLogForwarding(t)
|
||||
defer l.cleanup()
|
||||
|
||||
logToLogWriter(t, l, `{"level": "info","msg":"sync"}`)
|
||||
|
||||
@@ -73,6 +77,9 @@ type log struct {
|
||||
w io.WriteCloser
|
||||
file string
|
||||
done chan error
|
||||
|
||||
// TODO: use t.Cleanup after dropping support for Go 1.13
|
||||
cleanup func()
|
||||
}
|
||||
|
||||
func runLogForwarding(t *testing.T) *log {
|
||||
@@ -81,10 +88,6 @@ func runLogForwarding(t *testing.T) *log {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
logR.Close()
|
||||
logW.Close()
|
||||
})
|
||||
|
||||
tempFile, err := ioutil.TempFile("", "")
|
||||
if err != nil {
|
||||
@@ -92,7 +95,6 @@ func runLogForwarding(t *testing.T) *log {
|
||||
}
|
||||
tempFile.Close()
|
||||
logFile := tempFile.Name()
|
||||
t.Cleanup(func() { os.Remove(logFile) })
|
||||
|
||||
logConfig := Config{LogLevel: logrus.InfoLevel, LogFormat: "json", LogFilePath: logFile}
|
||||
loggingConfigured = false
|
||||
@@ -102,7 +104,13 @@ func runLogForwarding(t *testing.T) *log {
|
||||
|
||||
doneForwarding := ForwardLogs(logR)
|
||||
|
||||
return &log{w: logW, done: doneForwarding, file: logFile}
|
||||
cleanup := func() {
|
||||
os.Remove(logFile)
|
||||
logR.Close()
|
||||
logW.Close()
|
||||
}
|
||||
|
||||
return &log{w: logW, done: doneForwarding, file: logFile, cleanup: cleanup}
|
||||
}
|
||||
|
||||
func finish(t *testing.T, l *log) {
|
||||
|
||||
Reference in New Issue
Block a user