-
Notifications
You must be signed in to change notification settings - Fork 542
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
Remove TestListResolver#optionallyWildcardFilter #499
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,6 @@ | |
* under the License. | ||
*/ | ||
|
||
import junit.framework.TestCase; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collection; | ||
import java.util.Collections; | ||
|
@@ -29,12 +27,14 @@ | |
import java.util.LinkedHashSet; | ||
import java.util.Set; | ||
|
||
import static java.util.Collections.addAll; | ||
import static org.apache.maven.surefire.api.testset.TestListResolver.newTestListResolver; | ||
import static org.apache.maven.surefire.api.testset.ResolvedTest.Type.CLASS; | ||
import junit.framework.TestCase; | ||
|
||
import static java.util.Arrays.asList; | ||
import static java.util.Collections.addAll; | ||
import static java.util.Collections.emptySet; | ||
import static java.util.Collections.singleton; | ||
import static org.apache.maven.surefire.api.testset.ResolvedTest.Type.CLASS; | ||
import static org.apache.maven.surefire.api.testset.TestListResolver.newTestListResolver; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.Matchers.is; | ||
|
||
|
@@ -257,7 +257,7 @@ public void testShouldRunSuiteWithIncludedMethods() | |
|
||
public void testShouldRunAny() | ||
{ | ||
TestListResolver resolver = TestListResolver.getEmptyTestListResolver(); | ||
TestListResolver resolver = new TestListResolver( "" ); | ||
assertTrue( resolver.shouldRun( "pkg/MyTest.class", null ) ); | ||
|
||
resolver = new TestListResolver( Collections.<String>emptySet() ); | ||
|
@@ -365,7 +365,6 @@ public void testTestListResolverWithMethods() | |
assertTrue( resolver.shouldRun( "BTest.class", null ) ); | ||
assertFalse( resolver.shouldRun( "BTest.class", "failedTest" ) ); | ||
assertTrue( resolver.shouldRun( "CTest.class", null ) ); | ||
assertFalse( TestListResolver.optionallyWildcardFilter( resolver ).isEmpty() ); | ||
} | ||
|
||
private static Set<ResolvedTest> toSet( ResolvedTest... patterns ) | ||
|
@@ -401,19 +400,6 @@ public void testInclusiveWithDefaultExclusivePattern() | |
assertTrue( runnable ); | ||
} | ||
|
||
public void testWildcard() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This use case is still valid and the test should not be removed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but I removed ... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slawekjaranowski |
||
{ | ||
TestListResolver tlr = TestListResolver.optionallyWildcardFilter( new TestListResolver( (String) null ) ); | ||
assertThat( tlr, is( new TestListResolver( "**/*.class" ) ) ); | ||
assertThat( tlr.isWildcard(), is( true ) ); | ||
assertThat( tlr.isEmpty(), is( false ) ); | ||
|
||
tlr = TestListResolver.optionallyWildcardFilter( new TestListResolver( "**/**/MethodLessPattern.class" ) ); | ||
assertThat( tlr, is( new TestListResolver( "**/*.class" ) ) ); | ||
assertThat( tlr.isWildcard(), is( true ) ); | ||
assertThat( tlr.isEmpty(), is( false ) ); | ||
} | ||
|
||
public void testRegexRuleViolationQuotedHashMark() | ||
{ | ||
try | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ | |
import static org.apache.maven.surefire.common.junit4.Notifier.pureNotifier; | ||
import static org.apache.maven.surefire.api.report.ConsoleOutputCapture.startCapture; | ||
import static org.apache.maven.surefire.api.report.SimpleReportEntry.withException; | ||
import static org.apache.maven.surefire.api.testset.TestListResolver.optionallyWildcardFilter; | ||
import static org.apache.maven.surefire.api.util.TestsToRun.fromClass; | ||
import static org.apache.maven.surefire.api.util.internal.ObjectUtils.systemProps; | ||
import static org.junit.runner.Request.aClass; | ||
|
@@ -274,14 +273,13 @@ private void executeWithRerun( Class<?> clazz, Notifier notifier, RunModeSetter | |
{ | ||
JUnitTestFailureListener failureListener = new JUnitTestFailureListener(); | ||
notifier.addListener( failureListener ); | ||
boolean hasMethodFilter = testResolver != null && testResolver.hasMethodPatterns(); | ||
|
||
try | ||
{ | ||
try | ||
{ | ||
notifier.asFailFast( isFailFast() ); | ||
execute( clazz, notifier, hasMethodFilter ? createMethodFilter() : null ); | ||
execute( clazz, notifier, createMethodFilter() ); | ||
} | ||
finally | ||
{ | ||
|
@@ -432,7 +430,6 @@ private static boolean hasFilteredOutAllChildren( Description description ) | |
|
||
private Filter createMethodFilter() | ||
{ | ||
TestListResolver methodFilter = optionallyWildcardFilter( testResolver ); | ||
return methodFilter.isEmpty() || methodFilter.isWildcard() ? null : new TestResolverFilter( methodFilter ); | ||
return testResolver != null && testResolver.hasMethodPatterns() ? new TestResolverFilter( testResolver ) : null; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Wildcard class and wildcard method (i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed Test for master code: tlr = new TestListResolver( "*.class" );
assertTrue( tlr.isWildcard() );
assertFalse( tlr.hasMethodPatterns() );
tlr = new TestListResolver( "*#*" );
assertFalse( tlr.isWildcard() );
assertTrue( tlr.hasMethodPatterns() );
tlr = new TestListResolver( "**/*#*" );
assertFalse( tlr.isWildcard() );
assertTrue( tlr.hasMethodPatterns() );
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In expresion: TestListResolver methodFilter = optionallyWildcardFilter( testResolver );
return methodFilter.isEmpty() || methodFilter.isWildcard()
? null : new TestResolverFilter( methodFilter );
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @slawekjaranowski
|
||
} | ||
} |
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.
This is still a valid case.
If TLR is empty (nothing) or a wildcard (everything), the provider would ignore TLR. But both corner cases may happen in the config.
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.
only one case is true for
isWildcard
: