-
Notifications
You must be signed in to change notification settings - Fork 14
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
Issue182: Load recheck.ignore file by suite #193
Conversation
@@ -58,7 +62,7 @@ | |||
|
|||
private final Map<String, DefaultValueFinder> usedFinders = new HashMap<>(); | |||
private final TestReplayResultPrinter printer; | |||
private final GlobalIgnoreApplier ignoreApplier; | |||
private final Filter ignoreApplier; |
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 think changing the field name would also be a good idea:
private final Filter ignoreApplier; | |
private final Filter filter; |
final GlobalIgnoreApplier globalIgnoreApplier = RecheckIgnoreUtil.loadRecheckIgnore(); | ||
final GlobalIgnoreApplier suiteIgnoreApplier = RecheckIgnoreUtil.loadRecheckSuiteIgnore( getSuitePath() ); | ||
|
||
ignoreApplier = new CompoundFilter( Lists.newArrayList( globalIgnoreApplier, suiteIgnoreApplier ) ); |
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.
IMHO it is good to not rely on Guava if there is similar JDK method:
ignoreApplier = new CompoundFilter( Lists.newArrayList( globalIgnoreApplier, suiteIgnoreApplier ) ); | |
ignoreApplier = new CompoundFilter( Arrays.asList( globalIgnoreApplier, suiteIgnoreApplier ) ); |
@@ -18,13 +20,30 @@ | |||
public class LoadFilterWorker { | |||
|
|||
private final Counter counter; | |||
private final Optional<Path> ignoreFile; |
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 know that this is a controversial topic, but I wouldn't use Optional
in fields.
See Stuart Marks' (who works for the core libraries team in the JDK group at Oracle) talk "Optional – The Mother of All Bikesheds" from Devoxx 2016 at 54:04:
Why Not Use Optional in Fields?
- More a style issue than a correctness issue
- usually there's a better way to model absence of a value
- use of Optional in fields often arises from slavish desire to eliminate nullable fields
- remember, eliminating nulls isn't a goal of Optional
- Using Optional in fields…
- creates another object for every field
- introduces a dependent load from memory on every field read
- clutters up your code
- to what benefit? ability to chain methods?
@@ -51,7 +41,8 @@ void using_strange_stepText_should_be_normalized() throws Exception { | |||
} catch ( final Exception e ) { | |||
// ignore exception, fear AssertionErrors... | |||
} | |||
assertThat( check.wasCalled ).isTrue(); | |||
Mockito.verify( check ).createFileNamer( "de.retest.recheck.RecheckImplTest" ); |
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.
We almost always use static importants for this reduce noise.
@Test | ||
void loading_without_ignore_file_should_fail( @TempDir final Path root ) throws Exception { | ||
final LoadFilterWorker worker = new LoadFilterWorker( NopCounter.getInstance(), root.toFile() ); | ||
assertThrows( IllegalArgumentException.class, () -> worker.load() ); |
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.
We usually use AssertJ for assertions as they are—in our opinion—more flexible and readable.
* global project base is still the default * added minimum unit tests
* adds it to the global ignorer * adapted unit test
* both exception message and method name now reflect their current purpose
Sorry, only got around to this now - thanks for the adaptations and the link to the interesting talk! |
This pull request pertains to the first half of retest/recheck-web#182 :
The RetestImpl now loads a second, optional, suite-specific filter in addition to the already loaded global one.
The new suite filter is loaded from the suite's golden master directory. It is loaded with the same mechanism as the global filter (e.g., also allows for a rules file). One difference is that a missing suite filter is not logged as an error (but as a debug message).
The remaining part of issue 182 is adding the step-wise filters (called level 3 in issue 182)