Don't write output during tests

Removes the "\nPASS\n" print (since we only strip "PASS\n")

Test: m -j blueprint_tools
Change-Id: I31abd8474d92af29e1fa4c1ae5a940f6a588336d
This commit is contained in:
Dan Willemsen 2017-04-20 10:39:38 -07:00
parent 9ce4529614
commit 57a523863d
2 changed files with 7 additions and 6 deletions

View File

@ -47,14 +47,14 @@ var (
)
func main() {
exitCode, err := Main(os.Args[0], os.Args[1:])
exitCode, err := Main(os.Stdout, os.Args[0], os.Args[1:])
if err != nil {
fmt.Fprintln(os.Stderr, err.Error())
}
os.Exit(exitCode)
}
func Main(name string, args []string) (int, error) {
func Main(out io.Writer, name string, args []string) (int, error) {
if len(args) < 1 {
return 1, fmt.Errorf("usage: %s javac ...", name)
}
@ -78,7 +78,7 @@ func Main(name string, args []string) (int, error) {
// Process subprocess stdout asynchronously
errCh := make(chan error)
go func() {
errCh <- process(pr, os.Stdout)
errCh <- process(pr, out)
}()
// Wait for subprocess to finish

View File

@ -16,6 +16,7 @@ package main
import (
"bytes"
"io/ioutil"
"strconv"
"testing"
)
@ -82,7 +83,7 @@ func TestJavacColorize(t *testing.T) {
func TestSubprocess(t *testing.T) {
t.Run("failure", func(t *testing.T) {
exitCode, err := Main("test", []string{"sh", "-c", "exit 9"})
exitCode, err := Main(ioutil.Discard, "test", []string{"sh", "-c", "exit 9"})
if err != nil {
t.Fatal("unexpected error", err)
}
@ -92,7 +93,7 @@ func TestSubprocess(t *testing.T) {
})
t.Run("signal", func(t *testing.T) {
exitCode, err := Main("test", []string{"sh", "-c", "kill -9 $$"})
exitCode, err := Main(ioutil.Discard, "test", []string{"sh", "-c", "kill -9 $$"})
if err != nil {
t.Fatal("unexpected error", err)
}
@ -102,7 +103,7 @@ func TestSubprocess(t *testing.T) {
})
t.Run("success", func(t *testing.T) {
exitCode, err := Main("test", []string{"echo"})
exitCode, err := Main(ioutil.Discard, "test", []string{"echo"})
if err != nil {
t.Fatal("unexpected error", err)
}