mount: enable debug logging for the flaky TestMount test

The test case fails from time to time with an Input/Output error while
trying to access the snapshots directory.
This commit is contained in:
Michael Eischer
2023-05-01 18:03:17 +02:00
parent 8d971172c4
commit 1cb11ad8ad
2 changed files with 29 additions and 0 deletions

23
internal/debug/testing.go Normal file
View File

@@ -0,0 +1,23 @@
package debug
import (
"log"
"os"
"testing"
)
// TestLogToStderr configures debug to log to stderr if not the debug log is
// not already configured and returns whether logging was enabled.
func TestLogToStderr(t testing.TB) bool {
if opts.isEnabled {
return false
}
opts.logger = log.New(os.Stderr, "", log.LstdFlags)
opts.isEnabled = true
return true
}
func TestDisableLog(t testing.TB) {
opts.logger = nil
opts.isEnabled = false
}