alloy / lowdown

A Ruby client for the HTTP/2 version of the Apple Push Notification Service.
MIT License
120 stars 15 forks source link

Getting tests to pass in Jruby 9.0.5.0 #20

Closed delwaterman closed 3 years ago

delwaterman commented 8 years ago

This will get tests to pass in Jruby 9.0.5.0. There is a bug in Jruby 9.1.0 (https://github.com/jruby/jruby/issues/3778) which is preventing tests from passing in that build

delwaterman commented 8 years ago

I got the tests passing locally in JRuby. If you don't mind, would you enable travis to run jruby 9.0.5.0

alloy commented 8 years ago

Hey, awesome! Can you tell me how the issue of unicode chars in method names relates to this issue?

Regarding adding JRuby to Travis, that seems fine to me, but as I have not experience with JRuby, it would be helpful if you could do so as part of your PR and that I can merge it once that’s green.

delwaterman commented 8 years ago

Running tests in JRuby 9.1 I see:

  1) Error:
Lowdown::Certificate::with a non-universal certificate#test_0001_returns that it?s not a universal certificate:
NoMethodError: undefined method `test_0001_returns that it?s not a universal certificate' for #<#<Class:0x2849434b>:0x60bbacfc>
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:108:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:205:in `capture_exceptions'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:105:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:256:in `time_it'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:104:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest.rb:331:in `on_signal'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:276:in `with_info_handler'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:103:in `run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest.rb:778:in `run_one_method'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/parallel.rb:32:in `block in start'

  2) Error:
Lowdown::Certificate::with a universal certificate#test_0001_returns that it?s a universal certificate:
NoMethodError: undefined method `test_0001_returns that it?s a universal certificate' for #<#<Class:0x3c5dbdf8>:0x352c44a8>
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:108:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:205:in `capture_exceptions'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:105:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:256:in `time_it'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:104:in `block in run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest.rb:331:in `on_signal'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:276:in `with_info_handler'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/test.rb:103:in `run'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest.rb:778:in `run_one_method'
    /Users/orion.delwaterman/.rvm/gems/jruby-9.1/gems/minitest-5.8.4/lib/minitest/parallel.rb:32:in `block in start'

The method undefined issue looks like weird with minitest, but given the names of the method the rake test is trying to trigger, I assumed it was having problems with Unicode. But after a second pass it's just smart quotes:

# lowdown/test/certificate_test.rb
#...
it "returns that it’s not a universal certificate" do
# ...
it "returns that it’s a universal certificate" do

I can remove those and get it running in 9.1

alloy commented 8 years ago

Ah, boooo… but if that’s what it takes to run on JRuby then I’ll make an exception and cave this one time :) 👍

delwaterman commented 8 years ago

sigh this may take a while, travis is having some issues running jruby 9.0.5. I am looking into it right now.

delwaterman commented 8 years ago

@alloy Ok this now works for JRuby 9.0.5.0 and 9.1.0.0. Ready to go. Let me know if you have concerns about removing the Gemfile.lock from the repo

alloy commented 8 years ago

Why does using Ruby require the removal of Gemfile.lock?

delwaterman commented 8 years ago

So in general, I follow the practice of not checking in Gemfile.lock for gems:

http://yehudakatz.com/2010/12/16/clarifying-the-roles-of-the-gemspec-and-gemfile/

Specifically in this repo, if you switch from Ruby to JRuby the Gemfile.lock changes:

--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -30,10 +30,10 @@ GEM
       timers (>= 4.1.1)
     celluloid-supervision (0.20.5)
       timers (>= 4.1.1)
-    hitimes (1.2.3)
+    hitimes (1.2.3-java)
     http-2 (0.8.1)
     minitest (5.8.4)
-    nio4r (1.2.0)
+    nio4r (1.2.0-java)
     parser (2.3.0.2)
       ast (~> 2.2)
     powerpack (0.1.1)
@@ -50,6 +50,7 @@ GEM
     yard (0.8.7.6)

So the problem is that the Gemfile.lock implies MRI ruby instead of allowing for JRuby. So following best practices its best to ignore this file in the repo and use .gemspec to lock down specific versions.

alloy commented 8 years ago

Ah I see, I forgot there were JRuby platform specific gems. Cool, seems good then 👍

But let’s hold off on merging it until you got a bit further with the cipher issue, so that the tool doesn’t only seem to support JRuby on paper.