diff --git a/ginkgo/testsuite/test_suite.go b/ginkgo/testsuite/test_suite.go index 09b16015a..9de8c2bb4 100644 --- a/ginkgo/testsuite/test_suite.go +++ b/ginkgo/testsuite/test_suite.go @@ -53,7 +53,7 @@ func SuitesInDir(dir string, recurse bool) []TestSuite { } files, _ := ioutil.ReadDir(dir) - re := regexp.MustCompile(`_test\.go$`) + re := regexp.MustCompile(`^[^._].*_test\.go$`) for _, file := range files { if !file.IsDir() && re.Match([]byte(file.Name())) { suites = append(suites, New(dir, files)) diff --git a/ginkgo/testsuite/testsuite_test.go b/ginkgo/testsuite/testsuite_test.go index 7f89f18a8..7a0753bf5 100644 --- a/ginkgo/testsuite/testsuite_test.go +++ b/ginkgo/testsuite/testsuite_test.go @@ -51,6 +51,10 @@ var _ = Describe("TestSuite", func() { //non-go files in a nested directory writeFile("/redherring", "big_test.jpg", "package ginkgo", 0666) + //ginkgo tests in ignored go files + writeFile("/ignored", ".ignore_dot_test.go", `import "github.com/onsi/ginkgo"`, 0666) + writeFile("/ignored", "_ignore_underscore_test.go", `import "github.com/onsi/ginkgo"`, 0666) + //non-ginkgo tests in a nested directory writeFile("/professorplum", "professorplum_test.go", `import "testing"`, 0666) @@ -140,6 +144,13 @@ var _ = Describe("TestSuite", func() { }) }) + Context("when there are ginkgo tests that are ignored by go in the specified directory ", func() { + It("should come up empty", func() { + suites := SuitesInDir(filepath.Join(tmpDir, "ignored"), false) + Ω(suites).Should(BeEmpty()) + }) + }) + Context("when there are non-ginkgo tests in the specified directory", func() { It("should return an appropriately configured suite", func() { suites := SuitesInDir(filepath.Join(tmpDir, "professorplum"), false)