-
Notifications
You must be signed in to change notification settings - Fork 6
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
[CIVIS-9349] fix minitest instrumentation with mixins #134
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
anmarchenko
changed the title
fix minitest instrumentation with mixins
[CIVIS-9349] fix minitest instrumentation with mixins
Mar 11, 2024
anmarchenko
force-pushed
the
anmarchenko/minitest_ignored_tests
branch
from
March 12, 2024 08:20
c637993
to
e295925
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #134 +/- ##
========================================
Coverage 99.08% 99.08%
========================================
Files 156 164 +8
Lines 7102 7236 +134
Branches 300 304 +4
========================================
+ Hits 7037 7170 +133
- Misses 65 66 +1 ☔ View full report in Codecov by Sentry. |
anmarchenko
force-pushed
the
anmarchenko/minitest_ignored_tests
branch
from
March 12, 2024 08:28
eb75332
to
570e56c
Compare
romainkomorn-exdatadog
approved these changes
Mar 12, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #130.
Uses Ruby's
Module.const_source_location
method that is available since Ruby 2.7 to determine the source location of Minitest::Runnable subclass (test suite).Motivation
Bug reported in the linked issue shows that we did not pay enough attention to the fact that Minitest allows tests to be defined in shared modules and be mixed in any test suite. The current way to determine test suite's source location is brittle because it returns method's location which could be anything in this case. This worked fine for tests that didn't use mixins and for tests that used only mixins, but broke for tests that used both mixed in tests and normal tests.
Proposed fix is to use where the class constant is defined as test suite location (and method only as fallback). As we target Ruby 2.7+ support since GA, it is safe to use and works for all cases.
Tests
Tests using ActiveSupport and mixins are provided