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

fix: fixes the test skip when the --focus flag argument contains metacharacters. #787

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion config/config.go
Expand Up @@ -15,6 +15,7 @@ package config

import (
"flag"
"regexp"
"time"

"fmt"
Expand Down Expand Up @@ -139,7 +140,7 @@ func BuildFlagArgs(prefix string, ginkgo GinkgoConfigType, reporter DefaultRepor
}

for _, s := range ginkgo.FocusStrings {
result = append(result, fmt.Sprintf("--%sfocus=%s", prefix, s))
result = append(result, fmt.Sprintf("--%sfocus=%s", prefix, regexp.QuoteMeta(s)))
}

for _, s := range ginkgo.SkipStrings {
Expand Down
6 changes: 6 additions & 0 deletions integration/_fixtures/flags_tests/flags_test.go
Expand Up @@ -44,6 +44,12 @@ var _ = Describe("Testing various flags", func() {
})
})

Describe("--focus flag argument contains metacharacters", func() {
It("should MyMethod() $called", func() {
println("MyMethod")
})
})

It("should detect races", func(done Done) {
var a string
go func() {
Expand Down
24 changes: 20 additions & 4 deletions integration/flags_test.go
Expand Up @@ -30,7 +30,7 @@ var _ = Describe("Flags Specs", func() {
output := string(session.Out.Contents())

Ω(output).Should(ContainSubstring("Ran 3 samples:"), "has a measurement")
Ω(output).Should(ContainSubstring("11 Passed"))
Ω(output).Should(ContainSubstring("12 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("3 Skipped"))
Expand Down Expand Up @@ -88,7 +88,23 @@ var _ = Describe("Flags Specs", func() {
Ω(output).Should(ContainSubstring("3 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("0 Pending"))
Ω(output).Should(ContainSubstring("12 Skipped"))
Ω(output).Should(ContainSubstring("13 Skipped"))
})

It("should override the programmatic focus when the --focus flag argument contains metacharacters", func() {
session := startGinkgo(pathToTest, "--noColor", "--focus=should MyMethod() $called")
Eventually(session).Should(gexec.Exit(0))
output := string(session.Out.Contents())

Ω(output).Should(ContainSubstring("MyMethod"))
Ω(output).Should(ContainSubstring("1 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("0 Pending"))
Ω(output).Should(ContainSubstring("15 Skipped"))
})

It("should ... when method() ...", func() {
Expect(1).To(Equal(1))
})

It("should override the programmatic focus when told to skip", func() {
Expand All @@ -99,7 +115,7 @@ var _ = Describe("Flags Specs", func() {
Ω(output).ShouldNot(ContainSubstring("marshmallow"))
Ω(output).Should(ContainSubstring("chocolate"))
Ω(output).Should(ContainSubstring("smores"))
Ω(output).Should(ContainSubstring("11 Passed"))
Ω(output).Should(ContainSubstring("12 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("3 Skipped"))
Expand All @@ -113,7 +129,7 @@ var _ = Describe("Flags Specs", func() {
Ω(output).ShouldNot(ContainSubstring("marshmallow"))
Ω(output).Should(ContainSubstring("chocolate"))
Ω(output).Should(ContainSubstring("smores"))
Ω(output).Should(ContainSubstring("11 Passed"))
Ω(output).Should(ContainSubstring("12 Passed"))
Ω(output).Should(ContainSubstring("0 Failed"))
Ω(output).Should(ContainSubstring("1 Pending"))
Ω(output).Should(ContainSubstring("3 Skipped"))
Expand Down