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

Allow coverage to be displayed for focused specs #367

Merged
merged 2 commits into from
Aug 29, 2017
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
8 changes: 5 additions & 3 deletions ginkgo/run_command.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import (
"fmt"
"math/rand"
"os"
"strings"
"time"

"io/ioutil"
Copy link
Contributor Author

@joefitzgerald joefitzgerald Aug 10, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

goimports doing its thing. I'm happy to revert these lines if you'd prefer...

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no problem :)

"path/filepath"

"github.com/onsi/ginkgo/config"
"github.com/onsi/ginkgo/ginkgo/interrupthandler"
"github.com/onsi/ginkgo/ginkgo/testrunner"
"github.com/onsi/ginkgo/types"
"io/ioutil"
"path/filepath"
)

func BuildRunCommand() *Command {
Expand Down Expand Up @@ -121,7 +123,7 @@ func (r *SpecRunner) RunSpecs(args []string, additionalArgs []string) {
fmt.Printf("\nGinkgo ran %d %s in %s\n", numSuites, pluralizedWord("suite", "suites", numSuites), time.Since(t))

if runResult.Passed {
if runResult.HasProgrammaticFocus {
if runResult.HasProgrammaticFocus && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
fmt.Printf("Test Suite Passed\n")
fmt.Printf("Detected Programmatic Focus - setting exit status to %d\n", types.GINKGO_FOCUS_EXIT_CODE)
os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
Expand Down
2 changes: 1 addition & 1 deletion ginkgo_dsl.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func RunSpecsWithCustomReporters(t GinkgoTestingT, description string, specRepor
reporters[i] = reporter
}
passed, hasFocusedTests := globalSuite.Run(t, description, reporters, writer, config.GinkgoConfig)
if passed && hasFocusedTests {
if passed && hasFocusedTests && strings.TrimSpace(os.Getenv("GINKGO_EDITOR_INTEGRATION")) == "" {
fmt.Println("PASS | FOCUSED")
os.Exit(types.GINKGO_FOCUS_EXIT_CODE)
}
Expand Down
19 changes: 19 additions & 0 deletions integration/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package integration_test

import (
"fmt"
"os"
"regexp"
"runtime"
"strings"
Expand Down Expand Up @@ -98,6 +99,24 @@ var _ = Describe("Running Specs", func() {
Ω(output).Should(ContainSubstring("Test Suite Passed"))
Ω(output).Should(ContainSubstring("Detected Programmatic Focus - setting exit status to %d", types.GINKGO_FOCUS_EXIT_CODE))
})

Context("when the GINKGO_EDITOR_INTEGRATION environment variable is set", func() {
BeforeEach(func() {
os.Setenv("GINKGO_EDITOR_INTEGRATION", "true")
})
AfterEach(func() {
os.Setenv("GINKGO_EDITOR_INTEGRATION", "")
})
It("should exit with a status code of 0 to allow a coverage file to be generated", func() {
session := startGinkgo(tmpDir, "--noColor", "--succinct=false", "-r")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

Ω(output).Should(ContainSubstring("Running Suite: Passing_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Running Suite: More_ginkgo_tests Suite"))
Ω(output).Should(ContainSubstring("Test Suite Passed"))
})
})
})

Context("when told to skipPackages", func() {
Expand Down