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
ruby-rewrite
fails to actually rewrite the input file when a rewriter is loaded. This fixes the issue.
#162
ruby-rewrite
fails to actually rewrite the input file when a rewriter is loaded. This fixes the issue.
#162
Conversation
Test case to follow as soon as I figure out the right strategy for it. Suggestions on your preferred approach would be greatly appreciated. |
Your commit message is a bit confusing... could you use something like "- Always rewrite source file with original filename regardless of returned AST" ? Also, you don't have to recreate the PR. You can force-push the branch ( I think you can add a rewriter that would trigger the bug, and invoke the runner merely with "system", and then verify that the runner succeeded and the correct file was changed. You could name the file Thanks! |
The bug is that any rewriter at all will cause the file to not be rewritten. So the message "Always rewrite source file with original filename regardless of returned AST" is a touch misleading as it doesn't actually have anything to do with the AST. The approach you suggest is what came to mind after perusing the test suite. Glad to hear you find it acceptable! I'll also need a fixture file of course, so I'm inclined to bundle all three files into a sub-directory under |
(And once we suss out ideal commit message, I'll do a force-push here instead of re-submitting again...) |
Bug filed as #163 |
I've confirmed the new test case fails passes with the fix by running: ruby test/bug_163/test_runner_rewrite.rb And that it fails without the fix by running: git revert --no-commit 0e4e2037f11300f2c90f53c817e19f085999012e
ruby test/bug_163/test_runner_rewrite.rb |
In light of my clarification, suggested commit message? |
…ed, due to it getting confused about the filename.
ruby-rewrite
fails to actually rewrite the input file when a rewriter is loaded. This fixes the issue.
Clarifications provided. |
Erk. Travis shows green now: https://travis-ci.org/whitequark/parser/builds/33318214 |
class TestRunnerRewrite < Minitest::Test | ||
def setup | ||
@ruby_rewrite = BASE_DIR.expand_path + '../bin/ruby-rewrite' | ||
@tmp_dir = BASE_DIR + 'tmp' |
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.
Please use Dir.mktmpdir
for this.
Also, the commit messages for the tests shouldn't go into the changelog--so you need to remove the "- " prefix for them. Otherwise, your PR is fine. |
Will fix these up. Can you run |
@MrJoy That wouldn't work afaik, we'll need to wait until Travis updates images. |
Ok. I'm also tossing in a slight tweak that is apparently (waiting on Travis to confirm) harmless elsewhere but seemed to be needed for me to run the tests under Rubinius locally. I can back it out if you don't want. (See commit 1c3237d) |
Except for Rubinius issue, all's green in Travis. |
`ruby-rewrite` fails to actually rewrite the input file when a rewriter is loaded. This fixes the issue.
At the end of the
@rewriters.each
loop, the value ofbuffer.name
is no longer valid due to debugging annotations:This preserves the original name, allowing the file to be properly rewritten.