Skip to content

Commit

Permalink
Merge pull request #456 from idoru/ignore-suite-with-ignored-go-files
Browse files Browse the repository at this point in the history
Ignore packages whose tests are all ignored by go
  • Loading branch information
William Martin committed Apr 17, 2018
2 parents 68f622c + 7430ca7 commit 6d8be98
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion ginkgo/testsuite/test_suite.go
Expand Up @@ -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))
Expand Down
11 changes: 11 additions & 0 deletions ginkgo/testsuite/testsuite_test.go
Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 6d8be98

Please sign in to comment.