Skip to content

Commit 4152931

Browse files
committed
Invoke gotestsum correctly
1 parent 861daa9 commit 4152931

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

internal/cmd/build/main.go

+7-9
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ func (b *builder) integrationTest() error {
117117
runFlag := flagSet.String("run", "", "Passed to go test as -run")
118118
devServerFlag := flagSet.Bool("dev-server", false, "Use an embedded dev server")
119119
coverageFileFlag := flagSet.String("coverage-file", "", "If set, enables coverage output to this filename")
120-
junitFileFlag := flagSet.String("junitfile", "", "If set, a path prefix to which junit-style xml files should be written")
120+
junitFileFlag := flagSet.String("junitfile", "junit-xml", "If set, a path prefix to which junit-style xml files should be written")
121121
if err := flagSet.Parse(os.Args[2:]); err != nil {
122122
return fmt.Errorf("failed parsing flags: %w", err)
123123
}
@@ -172,10 +172,7 @@ func (b *builder) integrationTest() error {
172172
}
173173

174174
// Run integration test
175-
args := []string{"gotestsum", "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "10m"}
176-
if *junitFileFlag != "" {
177-
args = append(args, "--junitfile", *junitFileFlag+"-integration-test.xml")
178-
}
175+
args := []string{"gotestsum", "--junitfile", *junitFileFlag + "-integration-test.xml", "--", "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "10m"}
179176
if *runFlag != "" {
180177
args = append(args, "-run", *runFlag)
181178
}
@@ -238,7 +235,7 @@ func (b *builder) unitTest() error {
238235
flagSet := flag.NewFlagSet("unit-test", flag.ContinueOnError)
239236
runFlag := flagSet.String("run", "", "Passed to go test as -run")
240237
coverageFlag := flagSet.Bool("coverage", false, "If set, enables coverage output")
241-
junitFileFlag := flagSet.String("junitfile", "", "If set, a path prefix to which junit-style xml files should be written")
238+
junitFileFlag := flagSet.String("junitfile", "junit-xml", "If set, a path prefix to which junit-style xml files should be written")
242239
if err := flagSet.Parse(os.Args[2:]); err != nil {
243240
return fmt.Errorf("failed parsing flags: %w", err)
244241
}
@@ -272,9 +269,10 @@ func (b *builder) unitTest() error {
272269
log.Printf("Running unit tests in dirs: %v", testDirs)
273270
for _, testDir := range testDirs {
274271
// Run unit test
275-
args := []string{"gotestsum", "-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "15m"}
276-
if *junitFileFlag != "" {
277-
args = append(args, "--junitfile", *junitFileFlag+strings.ReplaceAll(testDir, "/", "-")+"unit-test.xml")
272+
args := []string{
273+
"gotestsum",
274+
"--junitfile", *junitFileFlag + strings.ReplaceAll(testDir, "/", "-") + "unit-test.xml", "--",
275+
"-tags", "protolegacy", "-count", "1", "-race", "-v", "-timeout", "15m",
278276
}
279277
if *runFlag != "" {
280278
args = append(args, "-run", *runFlag)

0 commit comments

Comments
 (0)