diff --git a/cmd/go2junit/go2junit.go b/cmd/go2junit/go2junit.go index b96dc0b..49bf657 100644 --- a/cmd/go2junit/go2junit.go +++ b/cmd/go2junit/go2junit.go @@ -8,9 +8,17 @@ import ( "log" "os" "path/filepath" + "runtime/debug" "strings" ) +func getVersion() string { + if info, ok := debug.ReadBuildInfo(); ok { + return info.Main.Version + } + return "unknown" +} + func (t *Test) MarshalXML(e *xml.Encoder, start xml.StartElement) error { if len(t.Tests) == 0 { start.Name = xml.Name{Local: "testcase"} @@ -50,6 +58,9 @@ func (t *Test) MarshalXML(e *xml.Encoder, start xml.StartElement) error { } func main() { + + fmt.Fprintf(os.Stderr, "go2junit version %s\n", getVersion()) + testsuites := Testsuites{} if len(os.Args) != 2 && len(os.Args) != 3 { @@ -146,7 +157,9 @@ func main() { if testsuites.Failures+testsuites.Errors+testsuites.Skipped+testsuites.Disabled > 0 { fmt.Printf("\nFAILED TESTS\n\n") printFailedTests("", "", testsuites.Suites) + os.Exit(1) } + os.Exit(0) } func printFailedTests(indent string, parentTest string, tests []*Test) {