Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore packages whose tests are all ignored by go #456

Merged
merged 1 commit into from
Apr 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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