Fix log silencing in tests

Tests were broken in Go 1.14.
pull/1/head
Marc-Antoine Ruel 6 years ago
parent 8284066f76
commit 816785ac40

@ -6,6 +6,7 @@ package bmxx80
import (
"errors"
"flag"
"io/ioutil"
"log"
"os"
@ -610,10 +611,6 @@ func TestI2CSenseContinuous280_command_fail(t *testing.T) {
}
func TestI2CSenseContinuous280_sense_fail(t *testing.T) {
if !testing.Verbose() {
log.SetOutput(ioutil.Discard)
defer log.SetOutput(os.Stderr)
}
bus := i2ctest.Playback{
Ops: []i2ctest.IO{
// Chip ID detection.
@ -1027,3 +1024,11 @@ type spiFail struct {
func (s *spiFail) Connect(f physic.Frequency, mode spi.Mode, bits int) (spi.Conn, error) {
return nil, errors.New("failing")
}
func TestMain(m *testing.M) {
flag.Parse()
if !testing.Verbose() {
log.SetOutput(ioutil.Discard)
}
os.Exit(m.Run())
}

@ -8,6 +8,7 @@ import (
"flag"
"io/ioutil"
"log"
"os"
"reflect"
"testing"
"time"
@ -230,8 +231,12 @@ func setupPlaybackIO() []i2ctest.IO {
func init() {
sleep = func(time.Duration) {}
}
func TestMain(m *testing.M) {
flag.Parse()
if !testing.Verbose() {
log.SetOutput(ioutil.Discard)
}
os.Exit(m.Run())
}

Loading…
Cancel
Save