-
Notifications
You must be signed in to change notification settings - Fork 21.9k
Replace method_source
gem with stdlib equivalent
#45904
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
Conversation
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, however I don't think it's really worth giving it its own file and unit testing it.
Can you move that class inside test_unit/runner.rb
and drop the tests? (assuming features relying on definition_for
are already tested)
964574d
to
7273f53
Compare
@byroot thanks, done!
For the most part this is true although I added one test for functionality that I didn't see exercised (using multiple line number test selection syntax with |
The `method_source` gem was added in rails#19216. It was used to determine the last line number of a given test method to support running tests by line number. But this is not something that requires an external dependency: Ripper can do this easily, and it has the added advantage of not using repeated calls to `eval` to do it. Drop `method_source` and replace it with a simple handler for Ripper's `on_def` parser event. I don't believe that there are any mainstream rubies at this point that can run Rails and don't support Ripper but correct me if I'm wrong.
7273f53
to
7690290
Compare
Looks great, thank you! I'll merge on green. |
This doesn't work with tests defined using |
Thanks @rafaelfranca, that makes sense. I guess there must have been missing test coverage for that and I didn't consider it. I'll retool and open a new PR that covers the test macro. |
Yeah, existing test wasn't failing but I updated it in the revert PR to fail with those code changes.
Thank you! Thank would be great. |
I spent a long time sitting on a half-finished version of this, but I've finally opened #46644. |
The `method_source` gem was added in rails#19216. It was used to determine the last line number of a given test method to support running tests by line number. But this is not something that requires an external dependency: Ripper can do this easily, and it has the added advantage of not using `eval` calls in a loop to do it as method_source does. It gets a bit trickier when dealing with declarative `test "some test"` style methods, but ripper can still handle those in a similar way. This is a second try at a PR (rails#45904) that got rolled back because the previous effort didn't handle the declarative test style.
The `method_source` gem was added in rails#19216. It was used to determine the last line number of a given test method to support running tests by line number. But this is not something that requires an external dependency: Ripper can do this easily, and it has the added advantage of not using `eval` calls in a loop to do it as method_source does. It gets a bit trickier when dealing with declarative `test "some test"` style methods, but ripper can still handle those in a similar way. This is a second try at a PR (rails#45904) that got rolled back because the previous effort didn't handle the declarative test style.
The
method_source
gem was added to railties in #19216. It was used to determine the last line number of a given test method to support running tests by line number. But this is not something that requires an external dependency: Ripper can do this easily, and it has the added advantage of not using repeated calls toeval
to do it.Drop
method_source
and replace it with a simple handler for Ripper'son_def
parser event.I don't believe that there are any mainstream rubies at this point that can run Rails and don't support Ripper but correct me if I'm mistaken.