From 9cd24c25d1d244e2132802a1f60ba132388a554e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Stemmer?= Date: Thu, 31 Mar 2022 22:46:17 +0100 Subject: [PATCH] Add -id flag to generate-golden to generate report for a single testcase --- testdata/generate-golden.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/testdata/generate-golden.go b/testdata/generate-golden.go index f4498a4..cf976ac 100644 --- a/testdata/generate-golden.go +++ b/testdata/generate-golden.go @@ -32,8 +32,10 @@ var fileSettings = map[string]Settings{ func main() { var writeFiles bool + var id int flag.BoolVar(&verbose, "v", false, "verbose logging") flag.BoolVar(&writeFiles, "w", false, "write output xml files") + flag.IntVar(&id, "id", 0, "generate report for given id only") flag.Parse() files, err := filepath.Glob("*.txt") @@ -41,7 +43,15 @@ func main() { exitf("error listing files: %v\n", err) } + var idPrefix string + if id > 0 { + idPrefix = fmt.Sprintf("%03d-", id) + } for _, file := range files { + if idPrefix != "" && !strings.HasPrefix(file, idPrefix) { + continue + } + outName := outputName(file) if err := createReportFromInput(file, outName, writeFiles); err != nil { logf("error creating report: %v\n", err)