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
diff --git a/cmd/javac_wrapper/javac_wrapper.go b/cmd/javac_wrapper/javac_wrapper.go
index a323473..ab4d23f 100644
--- a/cmd/javac_wrapper/javac_wrapper.go
+++ b/cmd/javac_wrapper/javac_wrapper.go
@@ -47,14 +47,14 @@
)
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 @@
// Process subprocess stdout asynchronously
errCh := make(chan error)
go func() {
- errCh <- process(pr, os.Stdout)
+ errCh <- process(pr, out)
}()
// Wait for subprocess to finish
diff --git a/cmd/javac_wrapper/javac_wrapper_test.go b/cmd/javac_wrapper/javac_wrapper_test.go
index 9f41078..c345479 100644
--- a/cmd/javac_wrapper/javac_wrapper_test.go
+++ b/cmd/javac_wrapper/javac_wrapper_test.go
@@ -16,6 +16,7 @@
import (
"bytes"
+ "io/ioutil"
"strconv"
"testing"
)
@@ -82,7 +83,7 @@
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 @@
})
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 @@
})
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)
}