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

When the --focus flag argument contains metacharacters the test skips. #786

Closed
joselitofilho opened this issue Mar 20, 2021 · 5 comments · May be fixed by #787
Closed

When the --focus flag argument contains metacharacters the test skips. #786

joselitofilho opened this issue Mar 20, 2021 · 5 comments · May be fixed by #787
Labels
wontfix Issues that won't be fixed and can be removed soon

Comments

@joselitofilho
Copy link
Contributor

joselitofilho commented Mar 20, 2021

Running this focused test with --focus="should MyMethod() $called":

It("should MyMethod() $called", func() {
    println("MyMethod")
})

Output:

ginkgo -focus "Testing various flags the focused set --focus flag argument contains metacharacters should MyMethod() $called"

Running Suite: Flags Suite
==========================
Random Seed: 1616239881
Will run 0 of 16 specs

SSSSSSSSSSSSSSSS
Ran 0 of 16 Specs in 0.016 seconds
SUCCESS! -- 0 Passed | 0 Failed | 0 Pending | 16 Skipped
PASS

Ginkgo ran 1 suite in 2.8910226s
Test Suite Passed

However, if I running without the --focus flag was set it runs.

I've been working on it. Can I open a PR for this?

@onsi
Copy link
Owner

onsi commented Mar 20, 2021

hey @joselitofilho - i appreciate the behavior is a bit confusing, but --focus (like go test -run) is actually designed to accept a regular expression. By quoting the metacharacters it becomes no longer possible for users to pass a meaningful regexp to --focus.

@joselitofilho
Copy link
Contributor Author

joselitofilho commented Mar 20, 2021

I got it @onsi.
I wonder if we could add another flag to accept regex. For example --focusx, --focux or --regex-focus. Something like that. Maybe help the newest users and give us more flexibility.

What do you think?

@onsi
Copy link
Owner

onsi commented Mar 20, 2021

My plan here - with v2 over the next couple of months - is to introduce labels. So users can annotate tests with labels and more explicitly control which tests they focus.

I assume your usecase has to do with the viscose plugin? For now I'd say you should escape the string in the plug-in. What i'm hoping to do in v2 is offer better support for programmatic interaction with ginkgo. Two ideas:

  1. ability to tell ginkgo to focus on a given source file + line number.

  2. ability for ginkgo to emit a json formatted report

thoughts on those two ideas?

@joselitofilho
Copy link
Contributor Author

joselitofilho commented Mar 20, 2021

My plan here - with v2 over the next couple of months - is to introduce labels. So users can annotate tests with labels and more explicitly control which tests they focus.

That sounds good. 🤓

I assume your usecase has to do with the viscose plugin?

Yes, it is. For now, I will recommend not using the metacharacters in the name of cases.

thoughts on those two ideas?

I appreciate that two ideas. Helps so much. Especially the second.

  1. ability for ginkgo to emit a json formatted report

Thanks, @onsi. I will close the PR. (or you, if you'd like to close it.)

Let me know if you'd like me to help you.

@joselitofilho
Copy link
Contributor Author

joselitofilho commented Mar 20, 2021

@onsi

One more thing. I think the ginkgo --focus behavior should not have the same behavior of go test -run in relation to regex. They are slightly different. I mean, the go test -run will apply the regex in the name of the test methods, the ginkgo --focus will apply regex in the text of the BDD cases.

It's just a question to think about. 😃

@onsi onsi closed this as completed Apr 4, 2021
@onsi onsi added the wontfix Issues that won't be fixed and can be removed soon label Apr 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wontfix Issues that won't be fixed and can be removed soon
Projects
None yet
2 participants