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

Load ignore files/rules per step #267

Closed
wants to merge 6 commits into from
Closed

Load ignore files/rules per step #267

wants to merge 6 commits into from

Conversation

hansi-b
Copy link

@hansi-b hansi-b commented May 31, 2019

This pull request proposes a solution for part 2 (level 3) of retest/recheck-web#182: Having an optional filter for each test step.

The two main changes are in RecheckImpl:

  1. It gets a new stateful field File currentStepDir (kept in a fashion similar to the already existing currentTestResult). This makes the information about the current step available in capTest to construct a step-specific filter from the suite filter.
  2. The former TestReplayResultPrinter field is now locally constructed in RecheckImpl::getDifferencesErrorMessage using the step-specific filter.

The loading of the step-specific filter delegates to the same logic used by the global and suite filters in RecheckIgnoreUtil. As with suite filters, a missing step filter will only log a debug message.


On a related note, the GlobalIgnoreApplier should perhaps be renamed: It is now used for 1. the global filter, 2. the suite filter, and 3. the step filter. It is rather like a mutable version of the CompoundFilter; it also happens to be the type used for loading and saving. So it seems to be something like a MutablePersistableCompoundFilter. IMHO, its inner class PersistableGlobalIgnoreApplier could also be replaced with a simpler list copy during (de)serialization.

and locally loaded step ignore files. Includes some prerequisite
refactorings:

* Made currentStepDir a state field similar to currentTestResult
  for access in capTest.
* The test printer has been changed from field to a local variable in
  capTest. (It is created on the fly with the step filter.)
* Renamed the filter field to suiteFilter to distinguish it from the
  specific test filter.
* Renamed filter loading methods in RecheckIgnoreUtil to reflect local
  vs. global filters. (The local one loads both suite and step filters.)
@beatngu13
Copy link
Contributor

Thanks a lot for the PR! 🙏 We will go through this ASAP.

Copy link
Contributor

@beatngu13 beatngu13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, just a few adjustments. 👍 Thinking about how a possible test could look like, but this requires a lot of I/O mocking I guess…

final Set<LeafDifference> uniqueDifferences = finishedTestResult.getDifferences( filter );

final GlobalIgnoreApplier stepIgnoreApplier = RecheckIgnoreUtil.loadRecheckIgnore( currentStepDir );
final Filter stepFilter = new CompoundFilter( Arrays.asList( suiteFilter, stepIgnoreApplier ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this need 3 filters?

  1. Global recheck.ignore
  2. Suite recheck.ignore
  3. Step recheck.ignore

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point - the three filters are already there, but in an obfuscated way: The global one is hiding in the misleadingly named suiteFilter, which is already constructed as a compound filter from global and suite filters in the constructor.
I guess we could either rename it to globalAndSuiteFilter (or similar) for clarification, or we can keep both filters in the RecheckImpl and then have the three item list you had expected. Any preference?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, indeed! I think globalAndSuiteFilter is a good idea. 👍

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh my! Good thing you asked about a test: It made me recheck my manual HTML test example to see if I could extract something unit-like. Instead, after a few trials my palm met my forehead: The code has an elementary conceptual problem (which is obvious in hindsight, don't know how I missed it then):

Currently, it only loads one step filter in RecheckImpl::capTest, i.e., only for the last step in a test. In general, RecheckImpl does step-wise stuff mostly via the ActionReplayResults, but capTest can currently only use one suite+global filter when finalizing the test results.

Unfortunately, I see no elegant way to fix this: Both TestReplayResult::getDifferences and the whole TestReplayResultPrinter currently also assume a single, constant filter when accumulating results from different ActionReplayResults. One alternative would be for them to use a Map<ActionReplayResult, Filter> to look up the (step-specific) filter per action; but this seems a little hackish to me, and it would change more public signatures and associated behaviour than this feature might be worth. I have checked these changes in so you can take a look yourself.

I have also verified the changed code with my little manual html test (which Github won't let me attach here, strangely), and I am very certain that it now works as desired, but I would understand completely if you think it might be better to close this pull request for the moment. (The suite filters, part 1 of this issue, are not affected.)

hansi-b and others added 2 commits June 11, 2019 20:46
Let SLF4J do the formatting (thanks to beatngu13!)

Co-Authored-By: Daniel Kraus <daniel.kraus@mailbox.org>
Copy link
Contributor

@beatngu13 beatngu13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rename the field and then I think we are good to go. In the meantime, I will try to come up with a test case (feel free to propose one). And if you want to, you can add yourself to the <contributors> section of the pom.xml.

final Set<LeafDifference> uniqueDifferences = finishedTestResult.getDifferences( filter );

final GlobalIgnoreApplier stepIgnoreApplier = RecheckIgnoreUtil.loadRecheckIgnore( currentStepDir );
final Filter stepFilter = new CompoundFilter( Arrays.asList( suiteFilter, stepIgnoreApplier ) );
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, indeed! I think globalAndSuiteFilter is a good idea. 👍

* It is a composition of the two.
* The step filter was only loaded in capTest, so only the filter from
  the last step would be applied.
* Now map action results to their respective filter instead.
* This entails some signature changes down the call chain, where only
  a single, constant filter across steps was used before.
@beatngu13
Copy link
Contributor

First of all: Sorry for the late reply!

Glad you find that issue—it is indeed not straightforward to come up with a proper solution. And as you said before, Map<ActionReplayResult, Filter> seems a bit hacky.

I would suggest to keep this PR open, we will discuss possible alternatives in retest/recheck-web#182. But in any case, we need tests for this (although we should probably wait until we know which way we want to go).

We will keep you updated, and thanks again for your contribution!

@martin-v martin-v removed their request for review September 2, 2019 13:10
@diba1013
Copy link
Contributor

diba1013 commented Nov 1, 2019

We decided that we currently do not have the resources to properly handle this PR (as probably stated due to the long time this PR was opened). However, we will revise this once there is need.

Again, thanks for the contribution and sorry for the long delay.

@diba1013 diba1013 closed this Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants