github.com/golang/dep@v0.5.4/internal/test/writer.go (about) 1 // Copyright 2017 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package test 6 7 import ( 8 "strings" 9 "testing" 10 "unicode" 11 ) 12 13 // Writer adapts a testing.TB to the io.Writer interface 14 type Writer struct { 15 testing.TB 16 } 17 18 func (t Writer) Write(b []byte) (n int, err error) { 19 str := string(b) 20 if len(str) == 0 { 21 return 0, nil 22 } 23 24 for _, part := range strings.Split(str, "\n") { 25 str := strings.TrimRightFunc(part, unicode.IsSpace) 26 if len(str) != 0 { 27 t.Log(str) 28 } 29 } 30 return len(b), err 31 }