-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add support for tests with parentheses at the end of the name #272
Conversation
46e1eb8
to
df89987
Compare
4647bb7
to
267db85
Compare
@@ -118,7 +118,7 @@ private boolean processSpockTest(TestFilterBuilder filters, TestsReader testsRea | |||
|
|||
private void addPotentiallyParameterizedSuffixed(TestFilterBuilder filters, String className, String name) { | |||
// It's a common pattern to add all the parameters on the end of a literal method name with [] | |||
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\)|\\[[^]]*?])*$", ""); | |||
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\))?(?:\\[[^]]*?](?:\\([^)]*?\\))?)?$", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤯
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, can we add a comment explaining what should match and what not? Or maybe a unit test?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've realised I made the regex more complicated than necessary. I've updated it to match only (...)
, or (...)[...]
, added a comment, and an additional test case in ParenthesesFuncTest
@@ -118,7 +118,7 @@ private boolean processSpockTest(TestFilterBuilder filters, TestsReader testsRea | |||
|
|||
private void addPotentiallyParameterizedSuffixed(TestFilterBuilder filters, String className, String name) { | |||
// It's a common pattern to add all the parameters on the end of a literal method name with [] | |||
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\)|\\[[^]]*?])*$", ""); | |||
String strippedParameterName = name.replaceAll("(?:\\([^)]*?\\))?(?:\\[[^]]*?](?:\\([^)]*?\\))?)?$", ""); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1, can we add a comment explaining what should match and what not? Or maybe a unit test?
...in/java/org/gradle/testretry/internal/executer/framework/BaseJunitTestFrameworkStrategy.java
Outdated
Show resolved
Hide resolved
plugin/src/test/groovy/org/gradle/testretry/ParenthesesFuncTest.groovy
Outdated
Show resolved
Hide resolved
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
Signed-off-by: Jean Gauthier <[email protected]>
4b280bd
to
9c1ba4b
Compare
BaseJunitTestFrameworkStrategy.addPotentiallyParameterizedSuffixed()
, to only remove(...)
, or(...)[...]
, without matching an arbitrary number of parentheses / brackets, as was the case up until nowAbstractPluginFuncTest.testLanguage()
and modifies the signature ofAbstractPluginFuncTest.writeTestSource
, to allow creating kotlin sample test classesParenthesesFuncTest
, that tests retry does not work with JUnitParamsRunner #101, Retry won't work with Kotlin parametrised tests enclosed in backticks #123, and "The following test methods could not be retried, which is unexpected" for the test method with parentheses in its name #263