forked from TrueCloudLab/restic
Merge pull request #4317 from MichaelEischer/debug-test-mount-failures
mount: enable debug logging for the flaky TestMount test
This commit is contained in:
commit
3e6a26e2e9
2 changed files with 29 additions and 0 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/restic/restic/internal/debug"
|
||||
"github.com/restic/restic/internal/repository"
|
||||
"github.com/restic/restic/internal/restic"
|
||||
rtest "github.com/restic/restic/internal/test"
|
||||
|
@ -159,6 +160,11 @@ func TestMount(t *testing.T) {
|
|||
t.Skip("Skipping fuse tests")
|
||||
}
|
||||
|
||||
debugEnabled := debug.TestLogToStderr(t)
|
||||
if debugEnabled {
|
||||
defer debug.TestDisableLog(t)
|
||||
}
|
||||
|
||||
env, cleanup := withTestEnvironment(t)
|
||||
// must list snapshots more than once
|
||||
env.gopts.backendTestHook = nil
|
||||
|
|
23
internal/debug/testing.go
Normal file
23
internal/debug/testing.go
Normal 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
|
||||
}
|
Loading…
Reference in a new issue