mirror of
https://github.com/octoleo/syncthing.git
synced 2024-09-11 01:19:00 +00:00
build: Add option to get test coverage (#5539)
This commit is contained in:
parent
d5ff2c41dc
commit
e2204d0071
5
.codecov.yml
Normal file
5
.codecov.yml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
coverage:
|
||||||
|
range: "40...100"
|
||||||
|
|
||||||
|
ignore:
|
||||||
|
- "**.pb.go"
|
22
build.go
22
build.go
@ -48,6 +48,7 @@ var (
|
|||||||
pkgdir string
|
pkgdir string
|
||||||
cc string
|
cc string
|
||||||
debugBinary bool
|
debugBinary bool
|
||||||
|
coverage bool
|
||||||
timeout = "120s"
|
timeout = "120s"
|
||||||
gogoProtoVersion = "v1.2.0"
|
gogoProtoVersion = "v1.2.0"
|
||||||
)
|
)
|
||||||
@ -330,24 +331,27 @@ func parseFlags() {
|
|||||||
flag.StringVar(&pkgdir, "pkgdir", "", "Set -pkgdir parameter for `go build`")
|
flag.StringVar(&pkgdir, "pkgdir", "", "Set -pkgdir parameter for `go build`")
|
||||||
flag.StringVar(&cc, "cc", os.Getenv("CC"), "Set CC environment variable for `go build`")
|
flag.StringVar(&cc, "cc", os.Getenv("CC"), "Set CC environment variable for `go build`")
|
||||||
flag.BoolVar(&debugBinary, "debug-binary", debugBinary, "Create unoptimized binary to use with delve, set -gcflags='-N -l' and omit -ldflags")
|
flag.BoolVar(&debugBinary, "debug-binary", debugBinary, "Create unoptimized binary to use with delve, set -gcflags='-N -l' and omit -ldflags")
|
||||||
|
flag.BoolVar(&coverage, "coverage", coverage, "Write coverage profile of tests to coverage.txt")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
}
|
}
|
||||||
|
|
||||||
func test(pkgs ...string) {
|
func test(pkgs ...string) {
|
||||||
lazyRebuildAssets()
|
lazyRebuildAssets()
|
||||||
|
|
||||||
useRace := runtime.GOARCH == "amd64"
|
args := []string{"test", "-short", "-timeout", timeout, "-tags", "purego"}
|
||||||
switch runtime.GOOS {
|
|
||||||
case "darwin", "linux", "freebsd": // , "windows": # See https://github.com/golang/go/issues/27089
|
if runtime.GOARCH == "amd64" {
|
||||||
default:
|
switch runtime.GOOS {
|
||||||
useRace = false
|
case "darwin", "linux", "freebsd": // , "windows": # See https://github.com/golang/go/issues/27089
|
||||||
|
args = append(args, "-race")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if useRace {
|
if coverage {
|
||||||
runPrint(goCmd, append([]string{"test", "-short", "-race", "-timeout", timeout, "-tags", "purego"}, pkgs...)...)
|
args = append(args, "-covermode", "atomic", "-coverprofile", "coverage.txt")
|
||||||
} else {
|
|
||||||
runPrint(goCmd, append([]string{"test", "-short", "-timeout", timeout, "-tags", "purego"}, pkgs...)...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runPrint(goCmd, append(args, pkgs...)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func bench(pkgs ...string) {
|
func bench(pkgs ...string) {
|
||||||
|
Loading…
Reference in New Issue
Block a user