From 87b112440739f219f706bd7e48bc05327d88eee6 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Wed, 19 Nov 2008 12:52:30 -0800 Subject: [PATCH] gobuild: add coverage rule, ignore files in package main. R=r DELTA=55 (41 added, 11 deleted, 3 changed) OCL=19594 CL=19598 --- src/cmd/gobuild/gobuild.c | 9 +++++++++ src/lib/fmt/Makefile | 4 ++++ src/lib/http/Makefile | 21 +++++++-------------- src/lib/math/Makefile | 4 ++++ src/lib/net/Makefile | 4 ++++ src/lib/os/Makefile | 4 ++++ src/lib/reflect/Makefile | 4 ++++ src/lib/strconv/Makefile | 4 ++++ src/lib/syscall/Makefile | 4 ++++ 9 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/cmd/gobuild/gobuild.c b/src/cmd/gobuild/gobuild.c index f0ba6f6719..1056d883ad 100644 --- a/src/cmd/gobuild/gobuild.c +++ b/src/cmd/gobuild/gobuild.c @@ -227,6 +227,9 @@ getpkg(char *file) return pkg[i]; } } + // don't put main in the package list + if(strcmp(p, "main") == 0) + return "main"; npkg++; pkg = erealloc(pkg, npkg*sizeof pkg[0]); pkg[i] = emalloc(strlen(p)+1); @@ -285,6 +288,10 @@ char preamble[] = "test: packages\n" "\tgotest\n" "\n" + "coverage: packages\n" + "\tgotest\n" + "\t6cov -g `pwd` | grep -v '^test.*\\.go:'\n" + "\n" "%%.$O: %%.go\n" "\t$(GC) $*.go\n" "\n" @@ -485,6 +492,8 @@ main(int argc, char **argv) job[njob].name = argv[i]; job[njob].pass = -1; job[njob].pkg = getpkg(argv[i]); + if(job[njob].pkg && strcmp(job[njob].pkg, "main") == 0) + continue; njob++; } diff --git a/src/lib/fmt/Makefile b/src/lib/fmt/Makefile index bdef02d698..3940622352 100644 --- a/src/lib/fmt/Makefile +++ b/src/lib/fmt/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/http/Makefile b/src/lib/http/Makefile index 0827008f97..57b06192e0 100644 --- a/src/lib/http/Makefile +++ b/src/lib/http/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go @@ -39,11 +43,7 @@ O3=\ O4=\ server.$O\ -O5=\ - triv.$O\ - -http.a: a1 a2 a3 a4 a5 -main.a: a1 a2 a3 a4 a5 +http.a: a1 a2 a3 a4 a1: $(O1) $(AR) grc http.a url.$O @@ -61,26 +61,19 @@ a4: $(O4) $(AR) grc http.a server.$O rm -f $(O4) -a5: $(O5) - $(AR) grc main.a triv.$O - rm -f $(O5) - newpkg: clean $(AR) grc http.a - $(AR) grc main.a $(O1): newpkg $(O2): a1 $(O3): a2 $(O4): a3 -$(O5): a4 nuke: clean - rm -f $(GOROOT)/pkg/http.a $(GOROOT)/pkg/main.a + rm -f $(GOROOT)/pkg/http.a -packages: http.a main.a +packages: http.a install: packages cp http.a $(GOROOT)/pkg/http.a - cp main.a $(GOROOT)/pkg/main.a diff --git a/src/lib/math/Makefile b/src/lib/math/Makefile index d5318a60a5..0c5d5a1ee5 100644 --- a/src/lib/math/Makefile +++ b/src/lib/math/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/net/Makefile b/src/lib/net/Makefile index 1670e5ac30..8910e3aa39 100644 --- a/src/lib/net/Makefile +++ b/src/lib/net/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/os/Makefile b/src/lib/os/Makefile index d359b232e0..ad789c8b0a 100644 --- a/src/lib/os/Makefile +++ b/src/lib/os/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/reflect/Makefile b/src/lib/reflect/Makefile index 90aadda42f..68870a33a6 100644 --- a/src/lib/reflect/Makefile +++ b/src/lib/reflect/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/strconv/Makefile b/src/lib/strconv/Makefile index 6718dc3f59..454ef142fd 100644 --- a/src/lib/strconv/Makefile +++ b/src/lib/strconv/Makefile @@ -18,6 +18,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go diff --git a/src/lib/syscall/Makefile b/src/lib/syscall/Makefile index a35be213a3..d74c0c24e4 100644 --- a/src/lib/syscall/Makefile +++ b/src/lib/syscall/Makefile @@ -20,6 +20,10 @@ clean: test: packages gotest +coverage: packages + gotest + 6cov -g `pwd` | grep -v '^test.*\.go:' + %.$O: %.go $(GC) $*.go -- 2.50.0