|
48 | 48 | pkgdir string
|
49 | 49 | cc string
|
50 | 50 | debugBinary bool
|
| 51 | + coverage bool |
51 | 52 | timeout = "120s"
|
52 | 53 | gogoProtoVersion = "v1.2.0"
|
53 | 54 | )
|
@@ -330,24 +331,27 @@ func parseFlags() {
|
330 | 331 | flag.StringVar(&pkgdir, "pkgdir", "", "Set -pkgdir parameter for `go build`")
|
331 | 332 | flag.StringVar(&cc, "cc", os.Getenv("CC"), "Set CC environment variable for `go build`")
|
332 | 333 | flag.BoolVar(&debugBinary, "debug-binary", debugBinary, "Create unoptimized binary to use with delve, set -gcflags='-N -l' and omit -ldflags")
|
| 334 | + flag.BoolVar(&coverage, "coverage", coverage, "Write coverage profile of tests to coverage.txt") |
333 | 335 | flag.Parse()
|
334 | 336 | }
|
335 | 337 |
|
336 | 338 | func test(pkgs ...string) {
|
337 | 339 | lazyRebuildAssets()
|
338 | 340 |
|
339 |
| - useRace := runtime.GOARCH == "amd64" |
340 |
| - switch runtime.GOOS { |
341 |
| - case "darwin", "linux", "freebsd": // , "windows": # See https://github.com/golang/go/issues/27089 |
342 |
| - default: |
343 |
| - useRace = false |
| 341 | + args := []string{"test", "-short", "-timeout", timeout, "-tags", "purego"} |
| 342 | + |
| 343 | + if runtime.GOARCH == "amd64" { |
| 344 | + switch runtime.GOOS { |
| 345 | + case "darwin", "linux", "freebsd": // , "windows": # See https://github.com/golang/go/issues/27089 |
| 346 | + args = append(args, "-race") |
| 347 | + } |
344 | 348 | }
|
345 | 349 |
|
346 |
| - if useRace { |
347 |
| - runPrint(goCmd, append([]string{"test", "-short", "-race", "-timeout", timeout, "-tags", "purego"}, pkgs...)...) |
348 |
| - } else { |
349 |
| - runPrint(goCmd, append([]string{"test", "-short", "-timeout", timeout, "-tags", "purego"}, pkgs...)...) |
| 350 | + if coverage { |
| 351 | + args = append(args, "-covermode", "atomic", "-coverprofile", "coverage.txt") |
350 | 352 | }
|
| 353 | + |
| 354 | + runPrint(goCmd, append(args, pkgs...)...) |
351 | 355 | }
|
352 | 356 |
|
353 | 357 | func bench(pkgs ...string) {
|
|
0 commit comments