Skip to content
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
10 changes: 9 additions & 1 deletion ginkgo/testrunner/test_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type TestRunner struct {
parallelStream bool
goOpts map[string]interface{}
additionalArgs []string
stderr *bytes.Buffer
}

func New(suite testsuite.TestSuite, numCPU int, parallelStream bool, goOpts map[string]interface{}, additionalArgs []string) *TestRunner {
Expand All @@ -40,6 +41,7 @@ func New(suite testsuite.TestSuite, numCPU int, parallelStream bool, goOpts map[
parallelStream: parallelStream,
goOpts: goOpts,
additionalArgs: additionalArgs,
stderr: new(bytes.Buffer),
}

if !suite.Precompiled {
Expand Down Expand Up @@ -434,7 +436,7 @@ func (t *TestRunner) cmd(ginkgoArgs []string, stream io.Writer, node int) *exec.
cmd := exec.Command(path, args...)

cmd.Dir = t.Suite.Path
cmd.Stderr = stream
cmd.Stderr = io.MultiWriter(stream, t.stderr)
cmd.Stdout = stream

return cmd
Expand All @@ -456,10 +458,16 @@ func (t *TestRunner) run(cmd *exec.Cmd, completions chan RunResult) RunResult {
}

cmd.Wait()

exitStatus := cmd.ProcessState.Sys().(syscall.WaitStatus).ExitStatus()
res.Passed = (exitStatus == 0) || (exitStatus == types.GINKGO_FOCUS_EXIT_CODE)
res.HasProgrammaticFocus = (exitStatus == types.GINKGO_FOCUS_EXIT_CODE)

if strings.Contains(t.stderr.String(), "warning: no tests to run") {
res.Passed = false
fmt.Fprintf(os.Stderr, `Found no test suites, did you forget to run "ginkgo bootstrap"?`)
}

return res
}

Expand Down
5 changes: 5 additions & 0 deletions integration/_fixtures/no_test_fn/no_test_fn.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package no_test_fn

func StringIdentity(a string) string {
return a
}
13 changes: 13 additions & 0 deletions integration/_fixtures/no_test_fn/no_test_fn_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package no_test_fn_test

import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/ginkgo/integration/_fixtures/no_test_fn"
. "github.com/onsi/gomega"
)

var _ = Describe("NoTestFn", func() {
It("should proxy strings", func() {
Ω(StringIdentity("foo")).Should(Equal("foo"))
})
})
15 changes: 15 additions & 0 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,21 @@ var _ = Describe("Running Specs", func() {
})
})

Context("when there are test files but `go test` reports there are no tests to run", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
copyIn("no_test_fn", pathToTest)
})

It("suggests running ginkgo bootstrap", func() {
session := startGinkgo(tmpDir, "--noColor", "--skipPackage=other,focused", "-r")
Eventually(session).Should(gexec.Exit(1))
output := string(session.Err.Contents())

Ω(output).Should(ContainSubstring(`Found no test suites, did you forget to run "ginkgo bootstrap"?`))
})
})

Context("when told to randomizeSuites", func() {
BeforeEach(func() {
pathToTest = tmpPath("ginkgo")
Expand Down