57 lines
1.0 KiB
Go
57 lines
1.0 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"os"
|
|
"text/template"
|
|
|
|
"github.com/gobuffalo/packr/v2"
|
|
"github.com/joshdk/go-junit"
|
|
"github.com/pkg/errors"
|
|
)
|
|
|
|
var (
|
|
templateFile = ""
|
|
)
|
|
|
|
func init() {
|
|
flag.StringVar(&templateFile, "template", templateFile, "The template file to use")
|
|
}
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
files := flag.Args()
|
|
|
|
suites, err := junit.IngestFiles(files)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not ingest junit files"))
|
|
}
|
|
|
|
for _, s := range suites {
|
|
s.Aggregate()
|
|
}
|
|
|
|
templateBox := packr.New("template", "./template")
|
|
defaultReportTemplate, err := templateBox.FindString("report.md.tmpl")
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not find report template"))
|
|
}
|
|
|
|
tmpl, err := template.New("report").Parse(defaultReportTemplate)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "could not parse template"))
|
|
}
|
|
|
|
templateData := struct {
|
|
Suites []junit.Suite
|
|
}{
|
|
Suites: suites,
|
|
}
|
|
|
|
if err := tmpl.Execute(os.Stdout, templateData); err != nil {
|
|
panic(errors.Wrap(err, "could not execute template"))
|
|
}
|
|
|
|
}
|