Skip to content

Commit

Permalink
Ignore packages whose tests are all ignored by go
Browse files Browse the repository at this point in the history
  • Loading branch information
idoru authored and cf-buildpacks-eng committed Apr 12, 2018
1 parent 68f622c commit 7430ca7
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 7430ca7

Please sign in to comment.