Skip to content

Commit 34f390c

Browse files
committed
Correct application specs for later JRubies
- removes exception unwrapping workarounds - removes JRuby 1.6 specific specs - tests RUBYOPT with a supported flag on modern Ruby Signed-off-by: Chad Wilson <[email protected]>
1 parent 064b57c commit 34f390c

File tree

2 files changed

+3
-70
lines changed

2 files changed

+3
-70
lines changed

src/spec/ruby/rack/application_spec.rb

+3-55
Original file line numberDiff line numberDiff line change
@@ -352,57 +352,6 @@ def newRuntime() # use the current runtime instead of creating new
352352
should_eval_as_eql_to "Gem.loaded_specs['rack'].version.to_s", '1.3.6'
353353
end
354354

355-
# should not matter on 1.7.x due https://github.com/jruby/jruby/pull/123
356-
if JRUBY_VERSION < '1.7.0'
357-
it "does not load any features (until load path is adjusted)" do
358-
set_runtime_environment("false")
359-
# due to incorrectly detected jruby.home some container e.g. WebSphere 8
360-
# fail if things such as 'fileutils' get required during runtime init !
361-
362-
# TODO: WTF? JRuby magic - $LOADED_FEATURES seems to get "inherited" if
363-
# Ruby.newInstance(config) is called with the factory's defaultConfig,
364-
# but only if it's executed with bundler e.g. `bundle exec rake spec`
365-
#@runtime = app_factory.new_runtime
366-
@runtime = org.jruby.Ruby.newInstance
367-
app_factory.send :initRuntime, @runtime
368-
369-
#@runtime.evalScriptlet 'puts "initRuntime $LOADED_FEATURES: #{$LOADED_FEATURES.inspect}"'
370-
# NOTE: the above scriptlet behaves slightly different on Travis-CI
371-
# depending on whether jruby + JRUBY_OPTS="--1.9" is used and or using
372-
# jruby-19mode with the later the LOADED_FEATURES do get expanded e.g. :
373-
#
374-
# "/home/travis/builds/kares/jruby-rack/target/classes/rack/handler/servlet.rb",
375-
# "/home/travis/builds/kares/jruby-rack/target/classes/jruby/rack.rb",
376-
# "/home/travis/builds/kares/jruby-rack/target/classes/jruby/rack/environment.rb",
377-
# "java.rb",
378-
# "/home/travis/.rvm/rubies/jruby-1.6.8-d19/lib/ruby/site_ruby/shared/builtin/javasupport.rb",
379-
# "/home/travis/.rvm/rubies/jruby-1.6.8-d19/lib/ruby/site_ruby/shared/builtin/javasupport/java.rb",
380-
# ...
381-
#
382-
# compared to jruby --1.9 :
383-
#
384-
# "enumerator.jar",
385-
# "rack/handler/servlet.rb",
386-
# "jruby/rack.rb",
387-
# "jruby/rack/environment.rb",
388-
# "java.rb",
389-
# "builtin/javasupport.rb",
390-
# "builtin/javasupport/java.rb",
391-
# ...
392-
393-
reject_files =
394-
"p =~ /.jar$/ || " +
395-
"p =~ /^builtin/ || " +
396-
"p =~ /java.rb$/ || p =~ /jruby.rb$/ || " +
397-
"p =~ /jruby\\/java.*.rb/ || " +
398-
"p =~ /jruby\\/rack.*.rb/ || " +
399-
"p =~ /^rack\\/handler\\/servlet/"
400-
# NOTE: fails with JRuby 1.7 as it has all kind of things loaded e.g. :
401-
# thread.rb, rbconfig.rb, java.rb, lib/ruby/shared/rubygems.rb etc
402-
should_eval_as_eql_to "$LOADED_FEATURES.reject { |p| #{reject_files} }", []
403-
end
404-
end
405-
406355
it "initializes the $servlet_context global variable" do
407356
@runtime = app_factory.new_runtime
408357
should_not_eval_as_nil "defined?($servlet_context)"
@@ -429,10 +378,10 @@ def newRuntime() # use the current runtime instead of creating new
429378
set_config 'jruby.runtime.env', 'false'
430379
set_config 'jruby.runtime.env.rubyopt', 'true'
431380

432-
app_factory = app_factory_with_RUBYOPT '-rubygems'
381+
app_factory = app_factory_with_RUBYOPT '-W:no-deprecated'
433382
@runtime = app_factory.newRuntime
434383
should_eval_as_nil "ENV['HOME']"
435-
should_eval_as_eql_to "ENV['RUBYOPT']", '-rubygems'
384+
should_eval_as_eql_to "ENV['RUBYOPT']", '-W:no-deprecated'
436385
end
437386

438387
it "keeps RUBYOPT by default with empty ENV (backwards compat)" do
@@ -490,7 +439,7 @@ def newRuntime() # use the current runtime instead of creating new
490439

491440
private
492441

493-
def app_factory_with_RUBYOPT(rubyopt = '-rubygems')
442+
def app_factory_with_RUBYOPT(rubyopt)
494443
app_factory =
495444
Class.new(org.jruby.rack.DefaultRackApplicationFactory) do
496445

@@ -990,7 +939,6 @@ def createRackServletWrapper(runtime, rackup); end
990939
begin
991940
@shared_factory.init(@rack_context)
992941
rescue org.jruby.rack.RackInitializationException => e
993-
e = unwrap_native_exception(e)
994942
expect( e.message ).to eql 'java.lang.ArithmeticException: 42'
995943
else
996944
fail "expected to rescue RackInitializationException"

src/spec/ruby/spec_helper.rb

-15
Original file line numberDiff line numberDiff line change
@@ -57,21 +57,6 @@ def silence_warnings(&block)
5757
JRuby::Rack::Helpers.silence_warnings(&block)
5858
end
5959

60-
def unwrap_native_exception(e)
61-
# JRuby 1.6.8 issue :
62-
# begin
63-
# ...
64-
# rescue org.jruby.rack.RackInitializationException => e
65-
# # e is still wrapped in a NativeException !
66-
# e.cause.class.name == 'org.jruby.rack.RackInitializationException'
67-
# end
68-
if JRUBY_VERSION < '1.7.0'
69-
e.is_a?(NativeException) ? e.cause : e
70-
else
71-
e
72-
end
73-
end
74-
7560
@@servlet_30 = nil
7661

7762
def servlet_30?

0 commit comments

Comments
 (0)