bisync: fix io.PipeWriter not getting closed on tests

This commit is contained in:
nielash 2024-04-06 23:07:59 -04:00
parent 68c2ba74dd
commit f995ece64d

View File

@ -5,6 +5,7 @@ import (
"bytes" "bytes"
"log" "log"
"github.com/rclone/rclone/fs"
"github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
@ -12,6 +13,12 @@ import (
func CaptureOutput(fun func()) []byte { func CaptureOutput(fun func()) []byte {
logSave := log.Writer() logSave := log.Writer()
logrusSave := logrus.StandardLogger().Writer() logrusSave := logrus.StandardLogger().Writer()
defer func() {
err := logrusSave.Close()
if err != nil {
fs.Errorf(nil, "error closing logrusSave: %v", err)
}
}()
buf := &bytes.Buffer{} buf := &bytes.Buffer{}
log.SetOutput(buf) log.SetOutput(buf)
logrus.SetOutput(buf) logrus.SetOutput(buf)