Skip to content
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

Run tests against supported jRuby versions #4703

Merged
merged 2 commits into from
Sep 24, 2017
Merged

Conversation

rrosenblum
Copy link
Contributor

@rrosenblum rrosenblum commented Sep 5, 2017

This is related to #4686. We aren't running tests against all supported jRuby versions. It would be really nice if we could specify jruby-9.0 and jruby-9.1 to test against the latest versions. I know that we have had issues with the Travis aliases in the past. It seems like we should always run against jruby-head even if it is an allowed failure.

https://docs.travis-ci.com/user/languages/ruby/
http://rubies.travis-ci.org/

@rrosenblum rrosenblum force-pushed the travis branch 2 times, most recently from 399124c to ba1d3d1 Compare September 5, 2017 21:54
@rrosenblum rrosenblum changed the title Run tests against jRuby 9.1.x and head Run tests against supported jRuby versions Sep 5, 2017
.travis.yml Outdated
- jruby-9.0.5.0
- jruby-9.1.9.0
- jruby-head
- jruby-1.7.26
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I removed it from the list.

.travis.yml Outdated
@@ -3,7 +3,10 @@ cache: bundler
language: ruby
dist: trusty
rvm:
- jruby-9.0.1.0
- jruby-9.0.5.0
- jruby-9.1.9.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

JRuby 9.1.12 is actually available on Travis CI. For example rails/rails uses it.

https://travis-ci.org/rails/rails/jobs/271990276#L585-L586

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, updated.

I went based on what is listed on http://rubies.travis-ci.org/. This list doesn't appear to be fully up to date.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right. I don't know when list of http://rubies.travis-ci.org/ will be updated, but as far as I know Travis CI can use the new JRuby version based on RVM update.

@rrosenblum rrosenblum force-pushed the travis branch 2 times, most recently from 08650c6 to 16683b0 Compare September 6, 2017 13:29
@koic koic mentioned this pull request Sep 6, 2017
11 tasks
@koic
Copy link
Member

koic commented Sep 6, 2017

The build error of JRuby 9.1.12.0 in this PR is probably resolved in #4708.

However, there are matrices that can not be tested until the end.
https://travis-ci.org/bbatsov/rubocop/jobs/272483545#L692

It seems that Travis CI terminated due to a timeout of 50 minutes.
https://docs.travis-ci.com/user/customizing-the-build#Build-Timeouts

Below we can see that the build of JRuby 9.1.12.0 is slow.
https://travis-ci.org/bbatsov/rubocop/builds/272483540

This problem seems to need to be considered separately from the build error.

@rrosenblum
Copy link
Contributor Author

The build error of JRuby 9.1.12.0 in this PR is probably resolved in #4708.

Yes, swapping each_with_index for each fixed the problem.

.travis.yml Outdated
@@ -3,7 +3,9 @@ cache: bundler
language: ruby
dist: trusty
rvm:
- jruby-9.0.1.0
- jruby-9.0.5.0
- jruby-9.1.12.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the update. Just a few hours ago JRuby 9.1.13.0 was released (!) .
http://jruby.org/2017/09/06/jruby-9-1-13-0

This is already available on Travis CI. Would please you update it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This release includes bug fixes for Enumerable#each_with_index.
jruby/jruby#4724.

@bbatsov
Copy link
Collaborator

bbatsov commented Sep 8, 2017

It would be really nice if we could specify jruby-9.0 and jruby-9.1 to test against the latest versions. I know that we have had issues with the Travis aliases in the past. It seems like we should always run against jruby-head even if it is an allowed failure.

My main concern is that the test suit is already pretty slow and adding more builds to the matrix doesn't really help. Why would someone stick with 9.0 instead of upgrading to 9.1? For Rbx and JRuby we've traditionally use on CI just their latest stable version.

@rrosenblum
Copy link
Contributor Author

Why would someone stick with 9.0 instead of upgrading to 9.1

I am not familiar with jRuby's release schedule or their support of major and minor versions. I assumed a jump from 9.0 to 9.1 was similar to minor version updates in Ruby. I am fine removing tests for 9.0.

Unfortunately, the jRuby test failures are coming from 9.1 and not 9.0.

@rrosenblum
Copy link
Contributor Author

Travis run failure for jRuby 9.1.13.0

Error: Your application used more memory than the safety cap of 500M.
Specify -J-Xmx####M to increase it (#### = cap size in MB).
Specify -w for full java.lang.OutOfMemoryError: Java heap space stack trace

I wasn't expecting the error to be running out of memory. I am not sure what baseline memory usage for RuboCop in jRuby is, but 500M seems incredibly high.

@rrosenblum
Copy link
Contributor Author

Just ran the jRuby tests locally to compare memory usage. I wound up with 2 Java processes when running bundle exec spec. One process was 750M. The other was 300M.

@rrosenblum rrosenblum force-pushed the travis branch 2 times, most recently from 00ef180 to d8c64d2 Compare September 12, 2017 17:19
@rrosenblum
Copy link
Contributor Author

rrosenblum commented Sep 13, 2017

I am having a bit of trouble getting spec/rubocop/cop/style/string_literals_spec.rb:155 autocorrects words with non-ascii chars to work with RUBYOPT="-E ASCII". The test is a little weird because were are processing unicode characters with ASCII. jRuby complains about incompatible character encoding, and I'm not really sure how to handle this. It is related to #3017, #3189, and #3311.

Does anyone have any thoughts on this?

@deivid-rodriguez
Copy link
Contributor

@rrosenblum Having a look at this right now.

@deivid-rodriguez
Copy link
Contributor

@rrosenblum This should get tests passing

index ff7a9eda..80e3892b 100644
--- a/lib/rubocop/cop/util.rb
+++ b/lib/rubocop/cop/util.rb
@@ -295,8 +295,7 @@ module RuboCop
       end
 
       def compatible_external_encoding_for?(src)
-        src = src.dup if RUBY_VERSION < '2.3'
-        src.force_encoding(Encoding.default_external).valid_encoding?
+        src.dup.force_encoding(Encoding.default_external).valid_encoding?
       end
 
       def to_supported_styles(enforced_style)

@deivid-rodriguez
Copy link
Contributor

To optimize memory usage, you could instead add another check for jruby, to avoid dupping the string when not necessary.

@deivid-rodriguez
Copy link
Contributor

To clarify my previous comment, this is the simplest patch to get this passing

diff --git a/lib/rubocop/cop/util.rb b/lib/rubocop/cop/util.rb
index ff7a9eda..88d5d85b 100644
--- a/lib/rubocop/cop/util.rb
+++ b/lib/rubocop/cop/util.rb
@@ -295,7 +295,7 @@ module RuboCop
       end
 
       def compatible_external_encoding_for?(src)
-        src = src.dup if RUBY_VERSION < '2.3'
+        src = src.dup if RUBY_VERSION < '2.3' || RUBY_ENGINE == 'jruby'
         src.force_encoding(Encoding.default_external).valid_encoding?
       end

@rrosenblum
Copy link
Contributor Author

Thanks for the help @deivid-rodriguez. The tests passed locally. Hopefully the Travis build will be successful this time.

@Drenmi
Copy link
Collaborator

Drenmi commented Sep 18, 2017

🎉

@deivid-rodriguez
Copy link
Contributor

You're welcome! 😃

.travis.yml Outdated
@@ -23,6 +24,7 @@ matrix:
- rvm: jruby-9.0.1.0
Copy link
Contributor

@olleolleolle olleolleolle Sep 18, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The allow_failures section now contains a non-included matrix item. Remove the line - rvm: jruby-9.0.1.0

.travis.yml Outdated
matrix:
- 'TASK=spec'
- 'TASK=ascii_spec'
- 'TASK=internal_investigation'
matrix:
allow_failures:
- rvm: jruby-9.0.1.0
- rvm: jruby-9.1.13.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? jruby-9.0.1.0 was temporarily moved to allow_failures because of a CI problem unrelated to RuboCop. But it's working now and I think RuboCop still officially supports jruby by making sure it's build is green...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because jruby-9.0.1.0 is not in the list of rubies that are actually run on the CI.

Copy link
Contributor

@deivid-rodriguez deivid-rodriguez Sep 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean the "plus" part of the diff, not the removal. Why putting jruby-9.1.13.0 in allowed_failures?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same answer. 😛 9.0.1.0 was replaced with 9.1.13.0 in the list of rubies (L:6).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh. I see what you mean now @deivid-rodriguez. Got hung up on the number. Yeah. Should be passing now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get it. We were enforcing jruby to pass when using 9.0.1.0, then we temporarily removed it because of a CI issue, now we upgrade to 9.1.13.0 and things are working in CI. Shouldn't it be again not present in allowed_failures?

I understand if you want to split that change to a separate commit, I guess. But the final diff here should not include that in the allowed_failures list. Unless you'd like that change as a separate PR?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I would've spared the last comment if I had seen #4703 (comment) before 😄.

Yeah, should be passing now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@deivid-rodriguez Good catch. I wasn't really thinking when I made the change. I agree, since we support jRuby, we should enforce green builds. The build is passing in jRuby so I will remove it from the allowed_failures section.

@bbatsov bbatsov merged commit 7416bab into rubocop:master Sep 24, 2017
@koic koic mentioned this pull request Oct 10, 2017
11 tasks
koic added a commit to koic/rubocop that referenced this pull request Oct 10, 2017
Follow up for rubocop#4703.

JRuby 9.1.13 and 9.2.0.0-SNAPSHOT (head) are specified for Travis CI.

`Dir.tmpdir` on JRuby 9.1.6 or higher returns `/tmp`. It is not the
current directory.

JRuby 9.1.5 or lower
====================

```console
% cd /home/vagrant && rvm use jruby-9.1.5.0 && ruby -rtmpdir -ve 'p Dir.tmpdir'
Using /home/vagrant/.rvm/gems/jruby-9.1.5.0
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 OpenJDK 64-Bit Server VM
24.121-b00 on 1.7.0_121-b00 +jit [linux-x86_64]
/home/vagrant/.rvm/rubies/jruby-9.1.5.0/lib/ruby/stdlib/tmpdir.rb:40:
warning: shadowing outer local variable - dir
"/home/vagrant"
```

JRuby 9.1.6 or higher
=====================

```console
% cd /home/vagrant && rvm use jruby-9.1.6.0 && ruby -rtmpdir -ve 'p Dir.tmpdir'
Using /home/vagrant/.rvm/gems/jruby-9.1.6.0
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM
24.121-b00 on 1.7.0_121-b00 +jit [linux-x86_64]
"/tmp"
```

I think that this workaround code is unnecessary already.

Related Issue ... jruby/jruby#405
bbatsov pushed a commit that referenced this pull request Oct 10, 2017
Follow up for #4703.

JRuby 9.1.13 and 9.2.0.0-SNAPSHOT (head) are specified for Travis CI.

`Dir.tmpdir` on JRuby 9.1.6 or higher returns `/tmp`. It is not the
current directory.

JRuby 9.1.5 or lower
====================

```console
% cd /home/vagrant && rvm use jruby-9.1.5.0 && ruby -rtmpdir -ve 'p Dir.tmpdir'
Using /home/vagrant/.rvm/gems/jruby-9.1.5.0
jruby 9.1.5.0 (2.3.1) 2016-09-07 036ce39 OpenJDK 64-Bit Server VM
24.121-b00 on 1.7.0_121-b00 +jit [linux-x86_64]
/home/vagrant/.rvm/rubies/jruby-9.1.5.0/lib/ruby/stdlib/tmpdir.rb:40:
warning: shadowing outer local variable - dir
"/home/vagrant"
```

JRuby 9.1.6 or higher
=====================

```console
% cd /home/vagrant && rvm use jruby-9.1.6.0 && ruby -rtmpdir -ve 'p Dir.tmpdir'
Using /home/vagrant/.rvm/gems/jruby-9.1.6.0
jruby 9.1.6.0 (2.3.1) 2016-11-09 0150a76 OpenJDK 64-Bit Server VM
24.121-b00 on 1.7.0_121-b00 +jit [linux-x86_64]
"/tmp"
```

I think that this workaround code is unnecessary already.

Related Issue ... jruby/jruby#405
@rrosenblum rrosenblum deleted the travis branch February 26, 2018 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants