Skip to content

Commit

Permalink
Add the ability to use ./... to recursively test directories (#319)
Browse files Browse the repository at this point in the history
  • Loading branch information
tedkornish authored and onsi committed Jan 26, 2017
1 parent a23f924 commit bb93381
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
11 changes: 8 additions & 3 deletions ginkgo/main.go
Expand Up @@ -234,7 +234,7 @@ func complainAndQuit(complaint string) {
os.Exit(1)
}

func findSuites(args []string, recurse bool, skipPackage string, allowPrecompiled bool) ([]testsuite.TestSuite, []string) {
func findSuites(args []string, recurseForAll bool, skipPackage string, allowPrecompiled bool) ([]testsuite.TestSuite, []string) {
suites := []testsuite.TestSuite{}

if len(args) > 0 {
Expand All @@ -246,10 +246,15 @@ func findSuites(args []string, recurse bool, skipPackage string, allowPrecompile
continue
}
}
suites = append(suites, testsuite.SuitesInDir(arg, recurse)...)
recurseForSuite := recurseForAll
if strings.HasSuffix(arg, "/...") && arg != "/..." {
arg = arg[:len(arg)-4]
recurseForSuite = true
}
suites = append(suites, testsuite.SuitesInDir(arg, recurseForSuite)...)
}
} else {
suites = testsuite.SuitesInDir(".", recurse)
suites = testsuite.SuitesInDir(".", recurseForAll)
}

skippedPackages := []string{}
Expand Down
32 changes: 23 additions & 9 deletions integration/run_test.go
Expand Up @@ -278,15 +278,29 @@ var _ = Describe("Running Specs", func() {
})

Context("when all the tests pass", func() {
It("should run all the tests (in succinct mode) and succeed", func() {
session := startGinkgo(tmpDir, "--noColor", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
Context("with the -r flag", func() {
It("should run all the tests (in succinct mode) and succeed", func() {
session := startGinkgo(tmpDir, "--noColor", "-r", ".")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
Context("with a trailing /...", func() {
It("should run all the tests (in succinct mode) and succeed", func() {
session := startGinkgo(tmpDir, "--noColor", "./...")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

outputLines := strings.Split(output, "\n")
Ω(outputLines[0]).Should(MatchRegexp(`\[\d+\] Passing_ginkgo_tests Suite - 4/4 specs [%s]{4} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(outputLines[1]).Should(MatchRegexp(`\[\d+\] More_ginkgo_tests Suite - 2/2 specs [%s]{2} SUCCESS! \d+(\.\d+)?[muµ]s PASS`, regexp.QuoteMeta(denoter)))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
})

Expand Down

0 comments on commit bb93381

Please sign in to comment.