From 03cda2267165408c1502b6ea326ae16956b64bef Mon Sep 17 00:00:00 2001 From: John Millikin Date: Fri, 16 Mar 2018 16:09:48 -0700 Subject: [PATCH] Move `junit-formatter.go` to its own package for use as a library. This lets JUnit xml generation be integrated into larger tools instead of having to run the `go-junit-report` binary as a subprocess. --- junit-formatter.go => formatter/formatter.go | 2 +- go-junit-report.go | 3 ++- go-junit-report_test.go | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) rename junit-formatter.go => formatter/formatter.go (99%) diff --git a/junit-formatter.go b/formatter/formatter.go similarity index 99% rename from junit-formatter.go rename to formatter/formatter.go index f497303..a096b54 100644 --- a/junit-formatter.go +++ b/formatter/formatter.go @@ -1,4 +1,4 @@ -package main +package formatter import ( "bufio" diff --git a/go-junit-report.go b/go-junit-report.go index dcb68a3..5c2e433 100644 --- a/go-junit-report.go +++ b/go-junit-report.go @@ -5,6 +5,7 @@ import ( "fmt" "os" + "github.com/jstemmer/go-junit-report/formatter" "github.com/jstemmer/go-junit-report/parser" ) @@ -33,7 +34,7 @@ func main() { } // Write xml - err = JUnitReportXML(report, noXMLHeader, goVersionFlag, os.Stdout) + err = formatter.JUnitReportXML(report, noXMLHeader, goVersionFlag, os.Stdout) if err != nil { fmt.Printf("Error writing XML: %s\n", err) os.Exit(1) diff --git a/go-junit-report_test.go b/go-junit-report_test.go index da28d89..a8255d9 100644 --- a/go-junit-report_test.go +++ b/go-junit-report_test.go @@ -9,6 +9,7 @@ import ( "strings" "testing" + "github.com/jstemmer/go-junit-report/formatter" "github.com/jstemmer/go-junit-report/parser" ) @@ -849,7 +850,7 @@ func testJUnitFormatter(t *testing.T, goVersion string) { var junitReport bytes.Buffer - if err = JUnitReportXML(testCase.report, testCase.noXMLHeader, goVersion, &junitReport); err != nil { + if err = formatter.JUnitReportXML(testCase.report, testCase.noXMLHeader, goVersion, &junitReport); err != nil { t.Fatal(err) }