Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
a809abaf
Commit
a809abaf
authored
Jun 30, 2011
by
Russ Cox
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
govet: automate test
R=golang-dev, r CC=golang-dev
https://golang.org/cl/4629084
parent
054cf72b
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
src/cmd/govet/Makefile
src/cmd/govet/Makefile
+3
-0
src/cmd/govet/govet.go
src/cmd/govet/govet.go
+13
-12
src/pkg/Makefile
src/pkg/Makefile
+0
-1
No files found.
src/cmd/govet/Makefile
View file @
a809abaf
...
@@ -9,3 +9,6 @@ GOFILES=\
...
@@ -9,3 +9,6 @@ GOFILES=\
govet.go
\
govet.go
\
include
../../Make.cmd
include
../../Make.cmd
test testshort
:
$(TARG)
../../../test/errchk
$(TARG)
-printfuncs
=
'Warn:1,Warnf:1'
govet.go
src/cmd/govet/govet.go
View file @
a809abaf
...
@@ -379,23 +379,24 @@ func (f *File) checkPrint(call *ast.CallExpr, name string, skip int) {
...
@@ -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.
// 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
()
{
func
BadFunctionUsedInTests
()
{
fmt
.
Println
()
// niladic call
fmt
.
Println
()
// not an error
fmt
.
Println
(
"%s"
,
"hi"
)
// % in call to Println
fmt
.
Println
(
"%s"
,
"hi"
)
// ERROR "possible formatting directive in Println call"
fmt
.
Printf
(
"%s"
,
"hi"
,
3
)
// wrong # percents
fmt
.
Printf
(
"%s"
,
"hi"
,
3
)
// ERROR "wrong number of args in Printf call"
fmt
.
Printf
(
"%s%%%d"
,
"hi"
,
3
)
// right # percents
fmt
.
Printf
(
"%s%%%d"
,
"hi"
,
3
)
// correct
fmt
.
Printf
(
"%.*d"
,
3
,
3
)
// right # percents, with a *
fmt
.
Printf
(
"%.*d"
,
3
,
3
)
// correct
fmt
.
Printf
(
"%.*d"
,
3
,
3
,
3
)
// wrong # percents, with a *
fmt
.
Printf
(
"%.*d"
,
3
,
3
,
3
)
// ERROR "wrong number of args in Printf call"
printf
(
"now is the time"
,
"buddy"
)
// no %s
printf
(
"now is the time"
,
"buddy"
)
// ERROR "no formatting directive"
Printf
(
"now is the time"
,
"buddy"
)
// no %s
Printf
(
"now is the time"
,
"buddy"
)
// ERROR "no formatting directive"
Printf
(
"hi"
)
// ok
f
:=
new
(
File
)
f
:=
new
(
File
)
f
.
Warn
(
0
,
"%s"
,
"hello"
,
3
)
//
% in call to added function
f
.
Warn
(
0
,
"%s"
,
"hello"
,
3
)
//
ERROR "possible formatting directive in Warn call"
f
.
Warnf
(
0
,
"%s"
,
"hello"
,
3
)
//
wrong # %s in call to added function
f
.
Warnf
(
0
,
"%s"
,
"hello"
,
3
)
//
ERROR "wrong number of args in Warnf call"
}
}
type
BadTypeUsedInTests
struct
{
type
BadTypeUsedInTests
struct
{
X
int
"hello"
//
struct field not well-formed
X
int
"hello"
//
ERROR "struct field tag"
}
}
// printf is used by the test.
// printf is used by the test.
...
...
src/pkg/Makefile
View file @
a809abaf
...
@@ -241,7 +241,6 @@ NOTEST+=\
...
@@ -241,7 +241,6 @@ NOTEST+=\
../cmd/godoc
\
../cmd/godoc
\
../cmd/goinstall
\
../cmd/goinstall
\
../cmd/gotest
\
../cmd/gotest
\
../cmd/govet
\
../cmd/goyacc
\
../cmd/goyacc
\
../cmd/hgpatch
\
../cmd/hgpatch
\
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment