-
Notifications
You must be signed in to change notification settings - Fork 533
JRuby on Windows #480
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
JRuby on Windows #480
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
Signed-off-by: Andy Maleh <andy.am@gmail.com>
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,36 @@ | ||
language: ruby | ||
rvm: | ||
- 2.3 | ||
- 2.4 | ||
- 2.5 | ||
- 2.6 | ||
- 2.7 | ||
- ruby-head | ||
- jruby | ||
|
||
matrix: | ||
jobs: | ||
include: | ||
- rvm: 2.3 | ||
- rvm: 2.4 | ||
- rvm: 2.5 | ||
- rvm: 2.6 | ||
- rvm: 2.7 | ||
- rvm: ruby-head | ||
- rvm: jruby | ||
- name: "Ruby Windows" | ||
os: windows | ||
language: shell | ||
script: | ||
- bundle | ||
- bundle exec rake | ||
- name: "JRuby Windows" | ||
os: windows | ||
language: shell | ||
script: | ||
- export JAVA_HOME=${JAVA_HOME:-/c/jdk} | ||
- export PATH=${JAVA_HOME}/bin:${PATH} | ||
- choco install jdk8 -params 'installdir=c:\\jdk' -y | ||
- curl -L -o jruby-dist-9.2.13.0-bin.zip https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.2.13.0/jruby-dist-9.2.13.0-bin.zip | ||
- unzip jruby-dist-9.2.13.0-bin.zip | ||
- export PATH="$(pwd)/jruby-9.2.13.0/bin:$PATH" | ||
- jruby --version | ||
- jruby -S gem install bundler --no-document | ||
- jruby -S bundle | ||
- powershell rake | ||
allow_failures: | ||
- rvm: jruby | ||
- rvm: ruby-head | ||
- name: "Ruby Windows" | ||
- name: "JRuby Windows" | ||
fast_finish: true |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
|
||
class TestDiffWithNonDefaultEncoding < Test::Unit::TestCase | ||
def git_working_dir | ||
cwd = `pwd`.chomp | ||
cwd = FileUtils.pwd | ||
if File.directory?(File.join(cwd, 'files')) | ||
test_dir = File.join(cwd, 'files') | ||
elsif File.directory?(File.join(cwd, '..', 'files')) | ||
|
@@ -35,13 +35,15 @@ def setup | |
def test_diff_with_greek_encoding | ||
d = @git.diff | ||
patch = d.patch | ||
return unless Encoding.default_external == (Encoding::UTF_8 rescue Encoding::UTF8) # skip test on Windows / check UTF8 in JRuby instead | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this is quite right. What do you think about this: skip 'Encoding tests do not work in Windows' if windows_platform? On other platforms, these tests should work not matter what the external encoding is. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I forgot to mention... I have not ever seen There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. About your first question, if you can figure out a better way to skip tests on Windows, then power to you! After all, they do not work in their current form inside the Windows Command Prompt or Git Bash and I did not feel it was important enough for me to invest more time into it (especially given that there was zero coverage before to begin with, so any coverage now is better than nothing) About your second question, I learned this from a senior Ruby developer called Chris Sepic more than a decade ago while working at this Chicago suburb company, Leapfrog Online. Basically, in rare cases where you do not need to do anything with the error exception object, instead of doing this: begin
try_something
rescue => e
do_nothing_with_e
end You can drop the error exception object: begin
try_something
rescue
do_something
end And then finally, you can fold it into one line: try_something rescue do_something I don't advise using this in the majority of cases. I only used it because this was a test (not production code) and brevity helped keep things on one line. Specifically, there is this odd quirk about JRuby where it calls the encoding constant UTF8 instead of UTF_8, so instead of me writing something very long and elaborate to check it such as:
|
||
assert(patch.include?("-Φθγητ οπορτερε ιν ιδεριντ\n")) | ||
assert(patch.include?("+Φεθγιατ θρβανιτασ ρεπριμιqθε\n")) | ||
end | ||
|
||
def test_diff_with_japanese_and_korean_encoding | ||
d = @git.diff.path('test2.txt') | ||
patch = d.patch | ||
return unless Encoding.default_external == (Encoding::UTF_8 rescue Encoding::UTF8) # skip test on Windows / check UTF8 in JRuby instead | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same here. |
||
expected_patch = <<~PATCH.chomp | ||
diff --git a/test2.txt b/test2.txt | ||
index 87d9aa8..210763e 100644 | ||
|
Uh oh!
There was an error while loading. Please reload this page.
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.
How about shortening this to the more intention revealing:
Then move the existing code to fill in the new methods referenced above. Then add a test (or more) for each method.
Uh oh!
There was an error while loading. Please reload this page.
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.
Sure. I agree that the suggested refactorings into intention revealing methods make the code a lot more readable/understandable.