diff --git a/cmd/go2junit/go2junit.go b/cmd/go2junit/go2junit.go index c84af0f..57572f2 100644 --- a/cmd/go2junit/go2junit.go +++ b/cmd/go2junit/go2junit.go @@ -99,8 +99,8 @@ func main() { testsuites := Testsuites{} - if len(os.Args) != 2 { - fmt.Fprintf(os.Stderr, "Usage: go2junit \n") + if len(os.Args) != 2 && len(os.Args) != 3 { + fmt.Fprintf(os.Stderr, "Usage: go2junit []\n") os.Exit(1) } path := os.Args[1] @@ -109,6 +109,10 @@ func main() { if err != nil { panic(err) } + prefix := "" + if len(os.Args) == 3 { + prefix = os.Args[2] + } var file = os.Stdin @@ -127,26 +131,28 @@ func main() { //.fmt.Printf("Parsed %d:\n%v\n\n", lineno, item) + pkg := prefix + item.Package switch item.Action { case "start": - testsuites.Suite(item.Time, item.Package) + testsuites.Suite(item.Time, pkg) case "run": - testsuites.Test(item.Time, item.Package, item.Test) + fmt.Println() + testsuites.Test(item.Time, pkg, item.Test) case "output": - testsuites.Output(item.Time, item.Package, item.Test, item.Output) + testsuites.Output(item.Time, pkg, item.Test, item.Output) fmt.Printf("%s", item.Output) case "pause": - testsuites.Output(item.Time, item.Package, item.Test, "PAUSED") + testsuites.Output(item.Time, pkg, item.Test, "PAUSED") case "cont": - testsuites.Output(item.Time, item.Package, item.Test, "CONTINUED") + testsuites.Output(item.Time, pkg, item.Test, "CONTINUED") case "pass": - testsuites.Pass(item.Time, item.Package, item.Test, item.Elapsed) + testsuites.Pass(item.Time, pkg, item.Test, item.Elapsed) case "bench": - testsuites.Bench(item.Time, item.Package, item.Test, item.Output, item.Elapsed) + testsuites.Bench(item.Time, pkg, item.Test, item.Output, item.Elapsed) case "fail": - testsuites.Fail(item.Time, item.Package, item.Test, item.Elapsed) + testsuites.Fail(item.Time, pkg, item.Test, item.Elapsed) case "skip": - testsuites.Skip(item.Time, item.Package, item.Test) + testsuites.Skip(item.Time, pkg, item.Test) } } testsuites.Complete() diff --git a/cmd/go2junit/output.go b/cmd/go2junit/output.go index dde314f..437a5aa 100644 --- a/cmd/go2junit/output.go +++ b/cmd/go2junit/output.go @@ -2,7 +2,6 @@ package main import ( "encoding/xml" - "log" "strings" "time" ) @@ -76,7 +75,6 @@ func (testsuites *Testsuites) getRootSuite(t time.Time, pkg string, create bool) Skipped: 0, Timestamp: t, } - log.Printf("Adding suite %s", pkg) testsuites.Suites = append(testsuites.Suites, &suite) return &suite }