aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/presubmit_test.go (renamed from test/trailing_test.go)29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/trailing_test.go b/test/presubmit_test.go
index e4490df23..392cbe5fb 100644
--- a/test/trailing_test.go
+++ b/test/presubmit_test.go
@@ -1,5 +1,7 @@
package test
+// These tests check for meta level items, like trailing whitespace, correct file naming etc.
+
import (
"bufio"
"fmt"
@@ -30,7 +32,6 @@ func hasTrailingWhitespace(path string, info os.FileInfo, _ error) error {
return nil
}
- println("looking at", path)
file, err := os.Open(path)
if err != nil {
return nil
@@ -48,3 +49,29 @@ func hasTrailingWhitespace(path string, info os.FileInfo, _ error) error {
return scanner.Err()
}
+
+func TestFileNameHyphen(t *testing.T) {
+ err := filepath.Walk("..", hasHyphen)
+ if err != nil {
+ t.Fatal(err)
+ }
+}
+
+func hasHyphen(path string, info os.FileInfo, _ error) error {
+ // only for regular files, not starting with a . and those that are go files.
+ if !info.Mode().IsRegular() {
+ return nil
+ }
+ if strings.HasPrefix(path, "../.") {
+ return nil
+ }
+ if filepath.Ext(path) != ".go" {
+ return nil
+ }
+
+ if strings.Index(path, "-") > 0 {
+ return fmt.Errorf("file %q has a hyphen, please use underscores in file names", path)
+ }
+
+ return nil
+}