Add -subtest-mode flag to configure SubtestMode

This commit is contained in:
Joël Stemmer
2022-05-22 00:34:05 +01:00
parent 1b7027fde7
commit 9ad16898a8
3 changed files with 14 additions and 0 deletions

11
main.go
View File

@ -8,6 +8,7 @@ import (
"strings"
"github.com/jstemmer/go-junit-report/v2/internal/gojunitreport"
"github.com/jstemmer/go-junit-report/v2/parser/gotest"
)
var (
@ -26,6 +27,7 @@ var (
iocopy = flag.Bool("iocopy", false, "copy input to stdout; can only be used in conjunction with -out")
properties = make(keyValueFlag)
parser = flag.String("parser", "gotest", "set input parser: gotest, gojson")
mode = flag.String("subtest-mode", "", "set subtest `mode`: ignore-parent-results (subtest parents always pass), exclude-parents (subtest parents are excluded from the report)")
// debug flags
printEvents = flag.Bool("debug.print-events", false, "print events generated by the go test parser")
@ -52,6 +54,14 @@ func main() {
properties["go.version"] = *goVersionFlag
}
subtestMode := gotest.SubtestModeDefault
if *mode != "" {
var err error
if subtestMode, err = gotest.ParseSubtestMode(*mode); err != nil {
exitf("invalid value for -subtest-mode: %s\n", err)
}
}
if flag.NArg() != 0 {
fmt.Fprintf(os.Stderr, "invalid argument(s): %s\n", strings.Join(flag.Args(), " "))
fmt.Fprintf(os.Stderr, "%s does not accept positional arguments\n", os.Args[0])
@ -90,6 +100,7 @@ func main() {
Hostname: hostname,
PackageName: *packageName,
SkipXMLHeader: *noXMLHeader,
SubtestMode: subtestMode,
Properties: properties,
PrintEvents: *printEvents,
}