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

[Bug] --focus and --skip flags do not work as of v2.0.0 #1189

Closed
josephine-lee-helix opened this issue Apr 20, 2023 · 3 comments
Closed

[Bug] --focus and --skip flags do not work as of v2.0.0 #1189

josephine-lee-helix opened this issue Apr 20, 2023 · 3 comments

Comments

@josephine-lee-helix
Copy link

josephine-lee-helix commented Apr 20, 2023

Ginkgo docs and the CLI ginkgo help text indicate that we can run e.g. ginkgo --focus=dog to run only tests that contain "dog" in the description. The docs mention that label-based filtering is recommended, but that description-based --focus and --skip flags will continue to be supported.

These flags work on ginkgo v1.16.4.

However, on both v2.0.0 and v2.8.0, the --focus and --skip flag seems to be ignored, and ginkgo runs all tests in the specific package.

I have reproduced this in two separate ginkgo installations/company repos, one where downgrading v2.8.0 -> v1.16.4 caused the flags to work, and another where upgrading v1.16.4 -> v2.8.0 caused the flags to break. I have also tried the following syntaxes that all didn't work:

ginkgo --focus=dog
ginkgo --focus="dog"
ginkgo --focus "dog"
ginkgo -focus=dog

#1126 possibly describes a similar issue, but its example leaves the issue open to being caused by other things. Instead, given this example where only one test contains the string "Unique",

package test_test

import (
	"testing"

	. "github.com/onsi/ginkgo/v2"
	. "github.com/onsi/gomega"
)

func TestTest(t *testing.T) {
	RegisterFailHandler(Fail)
	RunSpecs(t, "Test Suite")
}

var _ = Describe("Unique test one", func() {
	It("should succeed", func() {
		GinkgoWriter.Println("foo")
	})
})

var _ = Describe("Test two", func() {
	It("should print", func() {
		GinkgoWriter.Println("foobar")
	})
})

, when I run ginkgo --focus=Unique, ginkgo still runs all the tests in the file, instead of just the first one.

It'd be useful to know if this is/isn't just me!

@onsi
Copy link
Owner

onsi commented Apr 20, 2023

hey thanks for the clear issue description. I've used your reproducer and just ran this locally. Here's the output I'm seeing:

image

which is working as expected. In the first invocation of ginkgo -v -focus=Unique I see just the first test run. In the second I see the [Tt]est regexp is honored correctly.

Can you confirm you've recompiled the Ginkgo CLI? (what's the output of ginkgo version?)

@josephine-lee-helix
Copy link
Author

Can you confirm you've recompiled the Ginkgo CLI? (what's the output of ginkgo version?)

Ah, thank you so much, and for your quick response! ginkgo version returned 1.16.5.

In case anyone else sees this, I needed to have run:

go install -mod=mod github.com/onsi/ginkgo/v2/ginkgo@latest

per these docs

@onsi
Copy link
Owner

onsi commented Apr 20, 2023

hey glad that worked out. going forward you should see a more helpful message when there's a version mismatch - but that's only available in recent cli version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants