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
Fix recheck of failures whith caching #556
Fix recheck of failures whith caching #556
Conversation
* Rely on mocking :within_timeframe? instead of time travel (previous dates were not consistent) and fix expectations on :add. * Also fix the log for the recheck failure test: it did not contain the actual URL, which was then of added as new URL => This reveals a bug in handling failure re-checks.
Codecov Report
@@ Coverage Diff @@
## master #556 +/- ##
=========================================
Coverage ? 98.17%
=========================================
Files ? 30
Lines ? 1969
Branches ? 0
=========================================
Hits ? 1933
Misses ? 36
Partials ? 0
Continue to review full report at Codecov.
|
I could have checked this already, but this misbehavior was apparently introduced recently (Nov 2019) with 85b67a0#diff-fe945704107273e5238902a425c3d386, and the logic was correct before then |
Hey, thanks for this! I really appreciate the careful PR. I have made a few slight changes to address the tests for issue 1; I thought there was a bit too much stubbing of I have to think a little bit more on point 2, primarily, what I was thinking at the time around it. |
Sure, time traveling is indeed more explicit about the cases we are assessing, and with consistent dates / logs the tests work equally well. |
@gjtorikian, does it make sense to start merging the fix currently in places for the major point 1 and defer further thoughts about point 2 to another dedicated issue? No being able to use caching due errors not being rechecked is quite a limitation. Would be cool to get this part fixed in a new upcoming release ;). |
Yeah, absolutely. Sorry I forgot about this one. I'll push a new patch release once the tests are green. |
Test is just Rubocop; this is out as 3.15.3. Thanks again! |
🎉 Great, thanks for the quick action! 🚀 |
According to the README
However, a few things do not work as expected, as shown in the following minimal example
with the relevant part of the log from the 2nd call being
There are two issues here:
https://fooooo.baaaar
, the URL is actually removed and added due to an issue with the trailing/
.This pull request concerns mainly point 1, which I believe is a genuine issue with
html-proofer/lib/html-proofer/cache.rb
Lines 121 to 125 in 65f7e99
Since I noticed that unit tests existed and were supposed to cover such case, I actually did a preliminary cleanup of a few cache-related tests, where the existing logs and the time traveling were often not consistent. See 821ff0f (details in the commit message) where the test about re-checking failures is broken as in the example above, with URLs not being re-checked.
The actual fix is committed in d0016ca (+ few minor later commits).
Just a small disclaimer: I really like html-proofer and was happy to investigate the issue and contribute (also being familiar with unit testing and mocking), despite being pretty new to Ruby. Hope I did not overlook (too many) things.
As for the point 2, this is possibly related to
effective_url
being used instead ofhref
when callinghandle_failure
(which eventually passes it to@cache.add
)html-proofer/lib/html-proofer/url_validator.rb
Lines 166 to 167 in 65f7e99
Not sure if there was a reason for preferring
effective_url
in this context, if not I can include in this PR switching tohref
(I would also have an uncommitted test for this).