Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(445)

Unified Diff: src/cmd/vet/main.go

Issue 7399051: code review 7399051: cmd/vet: silence error from type checker unless verbose... (Closed)
Patch Set: diff -r ebc229da2df9 https://code.google.com/p/go/ Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/cmd/vet/main.go
===================================================================
--- a/src/cmd/vet/main.go
+++ b/src/cmd/vet/main.go
@@ -137,7 +137,17 @@
os.Exit(exitCode)
}
-// doPackageDir analyzes the single package found in the directory, if there is one.
+// prefixDirectory places the directory name on the beginning of each name in the list.
+func prefixDirectory(directory string, names []string) {
+ if directory != "." {
+ for i, name := range names {
+ names[i] = filepath.Join(directory, name)
+ }
+ }
+}
+
+// doPackageDir analyzes the single package found in the directory, if there is one,
+// plus a test package, if there is one.
func doPackageDir(directory string) {
pkg, err := build.Default.ImportDir(directory, 0)
if err != nil {
@@ -149,14 +159,17 @@
warnf("cannot process directory %s: %s", directory, err)
return
}
- names := append(pkg.GoFiles, pkg.CgoFiles...)
- // Prefix file names with directory names.
- if directory != "." {
- for i, name := range names {
- names[i] = filepath.Join(directory, name)
- }
+ var names []string
+ names = append(names, pkg.CgoFiles...)
+ names = append(names, pkg.TestGoFiles...) // These are also in the "foo" package.
+ prefixDirectory(directory, names)
+ doPackage(names)
+ // Is there also a "foo_test" package? If so, do that one as well.
+ if len(pkg.XTestGoFiles) > 0 {
+ names = pkg.XTestGoFiles
+ prefixDirectory(directory, names)
+ doPackage(names)
}
- doPackage(names)
}
type Package struct {
@@ -201,7 +214,7 @@
}
// Type check the package.
_, err := context.Check(fs, astFiles)
- if err != nil {
+ if err != nil && *verbose {
warnf("%s", err)
}
for _, file := range files {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b