aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2011-06-30 10:26:11 -0400
committerRuss Cox <rsc@golang.org>2011-06-30 10:26:11 -0400
commita809abafa55b6e2c1d2292575b066c1f5860adee (patch)
tree85c6a5e70db2ca31d24a3c6021b74c1f9a048055
parent054cf72b56d7fb6953acccf775e548cce685b31f (diff)
downloadgo-a809abafa55b6e2c1d2292575b066c1f5860adee.tar.gz
go-a809abafa55b6e2c1d2292575b066c1f5860adee.zip
govet: automate test
R=golang-dev, r CC=golang-dev https://golang.org/cl/4629084
-rw-r--r--src/cmd/govet/Makefile3
-rw-r--r--src/cmd/govet/govet.go25
-rw-r--r--src/pkg/Makefile1
3 files changed, 16 insertions, 13 deletions
diff --git a/src/cmd/govet/Makefile b/src/cmd/govet/Makefile
index 291b271976..f565b78f5c 100644
--- a/src/cmd/govet/Makefile
+++ b/src/cmd/govet/Makefile
@@ -9,3 +9,6 @@ GOFILES=\
govet.go\
include ../../Make.cmd
+
+test testshort: $(TARG)
+ ../../../test/errchk $(TARG) -printfuncs='Warn:1,Warnf:1' govet.go
diff --git a/src/cmd/govet/govet.go b/src/cmd/govet/govet.go
index 28652676fd..5b24d2ff03 100644
--- a/src/cmd/govet/govet.go
+++ b/src/cmd/govet/govet.go
@@ -379,23 +379,24 @@ func (f *File) checkPrint(call *ast.CallExpr, name string, skip int) {
}
// This function never executes, but it serves as a simple test for the program.
-// Test with govet -printfuncs="Bad:1,Badf:1,Warn:1,Warnf:1" govet.go
+// Test with make test.
func BadFunctionUsedInTests() {
- fmt.Println() // niladic call
- fmt.Println("%s", "hi") // % in call to Println
- fmt.Printf("%s", "hi", 3) // wrong # percents
- fmt.Printf("%s%%%d", "hi", 3) // right # percents
- fmt.Printf("%.*d", 3, 3) // right # percents, with a *
- fmt.Printf("%.*d", 3, 3, 3) // wrong # percents, with a *
- printf("now is the time", "buddy") // no %s
- Printf("now is the time", "buddy") // no %s
+ fmt.Println() // not an error
+ fmt.Println("%s", "hi") // ERROR "possible formatting directive in Println call"
+ fmt.Printf("%s", "hi", 3) // ERROR "wrong number of args in Printf call"
+ fmt.Printf("%s%%%d", "hi", 3) // correct
+ fmt.Printf("%.*d", 3, 3) // correct
+ fmt.Printf("%.*d", 3, 3, 3) // ERROR "wrong number of args in Printf call"
+ printf("now is the time", "buddy") // ERROR "no formatting directive"
+ Printf("now is the time", "buddy") // ERROR "no formatting directive"
+ Printf("hi") // ok
f := new(File)
- f.Warn(0, "%s", "hello", 3) // % in call to added function
- f.Warnf(0, "%s", "hello", 3) // wrong # %s in call to added function
+ f.Warn(0, "%s", "hello", 3) // ERROR "possible formatting directive in Warn call"
+ f.Warnf(0, "%s", "hello", 3) // ERROR "wrong number of args in Warnf call"
}
type BadTypeUsedInTests struct {
- X int "hello" // struct field not well-formed
+ X int "hello" // ERROR "struct field tag"
}
// printf is used by the test.
diff --git a/src/pkg/Makefile b/src/pkg/Makefile
index ca6dcea9bc..575f51fec6 100644
--- a/src/pkg/Makefile
+++ b/src/pkg/Makefile
@@ -241,7 +241,6 @@ NOTEST+=\
../cmd/godoc\
../cmd/goinstall\
../cmd/gotest\
- ../cmd/govet\
../cmd/goyacc\
../cmd/hgpatch\