From f3360e61e108436941e7209219973be8edb11021 Mon Sep 17 00:00:00 2001 From: Tom Wilkie Date: Wed, 30 Sep 2015 08:01:02 +0000 Subject: [PATCH] Remove cover tool, this lives in tools.git now. --- Makefile | 10 ++-- test/gen_coverage_reports.sh | 2 +- testing/cover/cover.go | 97 ------------------------------------ 3 files changed, 5 insertions(+), 104 deletions(-) delete mode 100644 testing/cover/cover.go diff --git a/Makefile b/Makefile index 02ab27c5..3498f500 100644 --- a/Makefile +++ b/Makefile @@ -16,10 +16,9 @@ WEAVEWAIT_EXE=prog/weavewait/weavewait WEAVEHOSTS_EXE=prog/weavehosts/weavehosts NETCHECK_EXE=prog/netcheck/netcheck DOCKERTLSARGS_EXE=prog/docker_tls_args/docker_tls_args -COVER_EXE=testing/cover/cover RUNNER_EXE=testing/runner/runner -EXES=$(WEAVER_EXE) $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEHOSTS_EXE) $(NETCHECK_EXE) $(DOCKERTLSARGS_EXE) $(COVER_EXE) $(RUNNER_EXE) +EXES=$(WEAVER_EXE) $(SIGPROXY_EXE) $(WEAVEPROXY_EXE) $(WEAVEWAIT_EXE) $(WEAVEHOSTS_EXE) $(NETCHECK_EXE) $(DOCKERTLSARGS_EXE) $(RUNNER_EXE) WEAVER_UPTODATE=.weaver.uptodate WEAVEEXEC_UPTODATE=.weaveexec.uptodate @@ -46,7 +45,7 @@ NETGO_CHECK=@strings $@ | grep cgo_stub\\\.go >/dev/null || { \ } BUILD_FLAGS=-ldflags "-extldflags \"-static\" -X main.version $(WEAVE_VERSION)" -tags netgo -all: $(WEAVE_EXPORT) $(COVER_EXE) $(RUNNER_EXE) +all: $(WEAVE_EXPORT) $(RUNNER_EXE) travis: $(EXES) @@ -78,11 +77,10 @@ $(NETCHECK_EXE): prog/netcheck/netcheck.go $(SIGPROXY_EXE): prog/sigproxy/main.go $(WEAVEWAIT_EXE): prog/weavewait/main.go net/*.go $(WEAVEHOSTS_EXE): prog/weavehosts/weavehosts.go -$(COVER_EXE): testing/cover/cover.go $(RUNNER_EXE): testing/runner/runner.go $(DOCKERTLSARGS_EXE): prog/docker_tls_args/*.go -$(WEAVEWAIT_EXE) $(SIGPROXY_EXE) $(WEAVEHOSTS_EXE) $(COVER_EXE) $(RUNNER_EXE) $(DOCKERTLSARGS_EXE): +$(WEAVEWAIT_EXE) $(SIGPROXY_EXE) $(WEAVEHOSTS_EXE) $(RUNNER_EXE) $(DOCKERTLSARGS_EXE): go get -tags netgo ./$(@D) go build $(BUILD_FLAGS) -o $@ ./$(@D) @@ -108,7 +106,7 @@ $(WEAVE_EXPORT): $(IMAGES_UPTODATE) $(DOCKER_DISTRIB): curl -o $(DOCKER_DISTRIB) $(DOCKER_DISTRIB_URL) -tests: $(COVER_EXE) tools/.git +tests: tools/.git tools/test lint: tools/.git diff --git a/test/gen_coverage_reports.sh b/test/gen_coverage_reports.sh index 567cb0f3..8f9f3816 100755 --- a/test/gen_coverage_reports.sh +++ b/test/gen_coverage_reports.sh @@ -9,7 +9,7 @@ if [ -n "$CIRCLECI" ]; then done fi -$DIR/../testing/cover/cover +go get github.com/weaveworks/build-tools/cover cover ./coverage/* >profile.cov go tool cover -html=profile.cov -o coverage.html go tool cover -func=profile.cov -o coverage.txt diff --git a/testing/cover/cover.go b/testing/cover/cover.go deleted file mode 100644 index 4c5fcfd7..00000000 --- a/testing/cover/cover.go +++ /dev/null @@ -1,97 +0,0 @@ -package main - -import ( - "fmt" - "os" - "sort" - - "golang.org/x/tools/cover" -) - -func merge(p1, p2 *cover.Profile) *cover.Profile { - output := cover.Profile{ - FileName: p1.FileName, - Mode: p1.Mode, - } - - i, j := 0, 0 - for i < len(p1.Blocks) && j < len(p2.Blocks) { - bi, bj := p1.Blocks[i], p2.Blocks[j] - if bi.StartLine == bj.StartLine && bi.StartCol == bj.StartCol { - - if bi.EndLine != bj.EndLine || - bi.EndCol != bj.EndCol || - bi.NumStmt != bj.NumStmt { - panic("Not run on same source!") - } - - output.Blocks = append(output.Blocks, cover.ProfileBlock{ - StartLine: bi.StartLine, - StartCol: bi.StartCol, - EndLine: bi.EndLine, - EndCol: bi.EndCol, - NumStmt: bi.NumStmt, - Count: bi.Count + bj.Count, - }) - i++ - j++ - } else if bi.StartLine < bj.StartLine || bi.StartLine == bj.StartLine && bi.StartCol < bj.StartCol { - output.Blocks = append(output.Blocks, bi) - i++ - } else { - output.Blocks = append(output.Blocks, bj) - j++ - } - } - - for ; i < len(p1.Blocks); i++ { - output.Blocks = append(output.Blocks, p1.Blocks[i]) - } - - for ; j < len(p2.Blocks); j++ { - output.Blocks = append(output.Blocks, p2.Blocks[j]) - } - - return &output -} - -func print(profiles []*cover.Profile) { - fmt.Println("mode: atomic") - for _, profile := range profiles { - for _, block := range profile.Blocks { - fmt.Printf("%s:%d.%d,%d.%d %d %d\n", profile.FileName, block.StartLine, block.StartCol, - block.EndLine, block.EndCol, block.NumStmt, block.Count) - } - } -} - -// Copied from https://github.com/golang/tools/blob/master/cover/profile.go -type byFileName []*cover.Profile - -func (p byFileName) Len() int { return len(p) } -func (p byFileName) Less(i, j int) bool { return p[i].FileName < p[j].FileName } -func (p byFileName) Swap(i, j int) { p[i], p[j] = p[j], p[i] } - -func main() { - outputProfiles := map[string]*cover.Profile{} - for _, input := range os.Args[1:] { - inputProfiles, err := cover.ParseProfiles(input) - if err != nil { - panic(fmt.Sprintf("Error parsing %s: %v", input, err)) - } - for _, ip := range inputProfiles { - op := outputProfiles[ip.FileName] - if op == nil { - outputProfiles[ip.FileName] = ip - } else { - outputProfiles[ip.FileName] = merge(op, ip) - } - } - } - profiles := make([]*cover.Profile, 0, len(outputProfiles)) - for _, profile := range outputProfiles { - profiles = append(profiles, profile) - } - sort.Sort(byFileName(profiles)) - print(profiles) -}