-
-
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
Better integration tests #31
Conversation
The runner is pretty high-level, if tests are running without involving the cli offenses aren't being rejected
551c0f9
to
4f0e1e3
Compare
This moves most tests to run inline instead of spawning an extra process. This isn't only faster but also much more explicit in what is actually being tested against. A few tests are left intact for issues that actually manifested during live rubocop runs.
4f0e1e3
to
8a32f40
Compare
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.
LGTM 👍
Let's fix the conflict and merge it
Hm, there seems to be some incompatibility with how you apply autocorrect on early rubocop versions. Would you mind me bumping the minimum required version here already so I don't have to look into that only to remove it later anyways? Just passing in the older |
Yeah, I think we can do that given that 1.0.0 is more than 3 years old. |
The new test harness has issues with older versions and it's planned to bump to 1.45 anyways for its introduction of 3rd party templating support
Great to hear, should be all good now! |
Part of what I wanted to do for #30 but this is pretty big already. Pulled it out so it doesn't get unreviewable.
This pulls in the test harness of
rubocop-minitest
. Tests are easier to read, more explicit in what's happening, more broad in their expectations, and also just faster.The first commit hooks earlier into rubocop when irrelevant invalid offenses are removed, needed for
test_non_code_offenses
to work. Since the runner isn't involved anymore this test would otherwise fail. The test suites passes with this commit in isolation.InvestigationReport
has been added in rubocop 0.87 rubocop/rubocop@f8813e7Second commit is the rewrite. Since normally cops are tested one by one I needed to make some tweaks to the assertion module to make sense for this gem, where all cops are being run at once. I've isolated these changes to their own class. rubocop/rubocop-minitest#278 proposes to make the base assertions reusable by other gems, if that gets merged then this would be a drop in replacement.
I moved most of the tests to this new setup, but left those that clearly had something to do with some options being passed to rubocop, like the config test or the one with the cache. Most just asserted that offenses happened.
Test suite before: ~25.5 seconds
Test suite now: ~9.5 seconds