Skip to content

Commit

Permalink
Re-enable specs to run with included JRuby bundler
Browse files Browse the repository at this point in the history
Signed-off-by: Chad Wilson <[email protected]>
  • Loading branch information
chadlwilson committed Jun 22, 2024
1 parent a965a33 commit 15edd63
Show file tree
Hide file tree
Showing 11 changed files with 43 additions and 72 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,4 @@ DEPENDENCIES
rspec

BUNDLED WITH
2.4.19
2.3.26
7 changes: 4 additions & 3 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ task :unpack_gem => "target" do |t|
mkdir_p "target/vendor"
require 'rubygems/installer'
rack_dir = File.basename(gem_file).sub(/\.gem$/, '')
Gem::Installer.new(Gem::Package.new(gem_file), :unpack => true, :install_dir => rack_dir).unpack "#{target}/#{rack_dir}"
Gem::Package.new(gem_file).extract_files("#{target}/#{rack_dir}")
File.open("#{target}/vendor/rack.rb", "w") do |f|
f << "dir = File.dirname(__FILE__)\n"
f << "if dir =~ /.jar!/ && dir !~ /^file:/\n"
Expand Down Expand Up @@ -109,8 +109,9 @@ task :speconly => [ :resources, :test_resources ] do
opts = ENV['SPEC_OPTS'] ? ENV['SPEC_OPTS'] : %q{ --format documentation --color }
spec = ENV['SPEC'] || File.join(Dir.getwd, "src/spec/ruby/**/*_spec.rb")
opts = opts.split(' ').push *FileList[spec].to_a
exec = 'rspec'; exec = Gem.bin_path('rspec', exec) if ENV['FULL_BIN_PATH']
ruby "-Isrc/spec/ruby", "-rbundler/setup", "-S", exec, *opts

args = ENV['RUBY'].split(' ') + %w{-Isrc/spec/ruby -rbundler/setup -S rspec}
sh *args, *opts
end
end

Expand Down
66 changes: 16 additions & 50 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@

<properties>
<jruby.version>9.4.7.0</jruby.version>
<vendor.gems.path>vendor/gems</vendor.gems.path>
<bundler.version>2.4.19</bundler.version>
<bundler.local>false</bundler.local> <!-- true by default -->
<jruby.maven.plugins.version>3.0.3</jruby.maven.plugins.version>
<gem.home>${project.build.directory}/rubygems</gem.home>
</properties>
Expand Down Expand Up @@ -97,6 +94,7 @@
<groupId>org.jruby</groupId>
<artifactId>jruby-core</artifactId>
<version>${jruby.version}</version>
<scope>provided</scope>
</dependency>
<!-- JavaEE 6 APIs -->
<dependency>
Expand Down Expand Up @@ -147,24 +145,11 @@
<version>3.2.10.RELEASE</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>jruby-openssl</artifactId>
<version>0.9.6</version>
<type>gem</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>rubygems</groupId>
<artifactId>bundler</artifactId>
<version>${bundler.version}</version>
<type>gem</type>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1</version>
<scope>test</scope>
</dependency>
</dependencies>

Expand Down Expand Up @@ -233,26 +218,6 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jruby.maven</groupId>
<artifactId>gem-maven-plugin</artifactId>
<version>${jruby.maven.plugins.version}</version>
<configuration>
<includeOpenSSL>false</includeOpenSSL>
<gemHomes>
<provided>${gem.home}</provided>
</gemHomes>
</configuration>
<executions>
<execution>
<id>gem-install-bundler</id>
<phase>test</phase>
<goals>
<goal>initialize</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.jruby.maven</groupId>
<artifactId>bundler-maven-plugin</artifactId>
Expand All @@ -263,9 +228,9 @@
<phase>test</phase>
<goals><goal>install</goal></goals>
<configuration>
<jruby.version>${jruby.version}</jruby.version>
<!--<local>false</local>-->
<bundlerVersion>${bundler.version}</bundlerVersion>
<jrubyVersion>${jruby.version}</jrubyVersion>
<local>false</local>
<quiet>false</quiet>
</configuration>
</execution>
</executions>
Expand All @@ -274,24 +239,25 @@
<groupId>org.jruby.maven</groupId>
<artifactId>rake-maven-plugin</artifactId>
<version>${jruby.maven.plugins.version}</version>
<configuration>
<jrubyVersion>${jruby.version}</jrubyVersion>
</configuration>
<executions>
<!-- <execution>-->
<!-- <id>rake-spec</id>-->
<!-- <phase>test</phase>-->
<!-- <goals><goal>rake</goal></goals>-->
<!-- <configuration>-->
<!-- <jruby.version>${jruby.version}</jruby.version>-->
<!-- <args>speconly SKIP_SPECS=${maven.test.skip} FULL_BIN_PATH=true</args>-->
<!-- </configuration>-->
<!-- </execution>-->
<execution>
<id>rake-spec</id>
<phase>test</phase>
<goals><goal>rake</goal></goals>
<configuration>
<args>speconly SKIP_SPECS=${maven.test.skip}</args>
</configuration>
</execution>
<execution>
<!-- additional (ruby) generated resources -->
<id>rake-resources</id>
<phase>prepare-package</phase>
<!-- bind "late" so we do not run during compile/test-compile -->
<goals><goal>rake</goal></goals>
<configuration>
<jruby.version>${jruby.version}</jruby.version>
<args>resources VERSION=${project.version}</args>
</configuration>
</execution>
Expand Down
5 changes: 2 additions & 3 deletions src/spec/ruby/jruby/rack/app_layout_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,14 @@

shared_examples "FileSystemLayout" do

@@__work_dir__ = Dir.pwd

before do
@original_work_dir = Dir.pwd
require 'tmpdir'
Dir.chdir Dir.mktmpdir
end

after do
Dir.chdir @@__work_dir__
Dir.chdir @original_work_dir
end

it "sets app and public uri defaults based on a typical (Rails/Rack) app" do
Expand Down
14 changes: 8 additions & 6 deletions src/spec/ruby/jruby/rack/booter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@

after(:all) { JRuby::Rack.context = nil }

@@rack_env = ENV['RACK_ENV']
@@gem_path = Gem.path.dup
@@env_gem_path = ENV['GEM_PATH']
before do
@rack_env = ENV['RACK_ENV']
@gem_path = Gem.path.to_a
@env_gem_path = ENV['GEM_PATH']
end

after do
@@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env
Gem.path.replace(@@gem_path)
@@env_gem_path.nil? ? ENV.delete('GEM_PATH') : ENV['GEM_PATH'] = @@env_gem_path
@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @rack_env
Gem.path.replace(@gem_path)
@env_gem_path.nil? ? ENV.delete('GEM_PATH') : ENV['GEM_PATH'] = @env_gem_path
end

it "should determine the public html root from the 'public.root' init parameter" do
Expand Down
2 changes: 1 addition & 1 deletion src/spec/ruby/jruby/rack/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def expect_to_have_monkey_patched_chunked
should_eval_as_eql_to script, "1\nsecond"
end

ENV_COPY = ENV.dup
ENV_COPY = ENV.to_h

def initialize_rails(env = nil, servlet_context = @servlet_context)
if ! servlet_context || servlet_context.is_a?(String)
Expand Down
9 changes: 6 additions & 3 deletions src/spec/ruby/jruby/rack/rails_booter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
booter.app_path.should == "./WEB-INF"
end

@@rails_env = ENV['RAILS_ENV']; @@rack_env = ENV['RACK_ENV']
before do
@rails_env = ENV['RAILS_ENV']
@rack_env = ENV['RACK_ENV']
end

after do
@@rails_env.nil? ? ENV.delete('RAILS_ENV') : ENV['RAILS_ENV'] = @@rails_env
@@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @@rack_env
@rails_env.nil? ? ENV.delete('RAILS_ENV') : ENV['RAILS_ENV'] = @rails_env
@rack_env.nil? ? ENV.delete('RACK_ENV') : ENV['RACK_ENV'] = @rack_env
end

it "should default rails path to /WEB-INF" do
Expand Down
4 changes: 2 additions & 2 deletions src/spec/ruby/jruby/rack/response_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,11 @@ def with_swallow_client_abort(client_abort = true)

private

def update_response_headers(headers, response = response)
def update_response_headers(headers, response)
response.to_java.getHeaders.update(headers)
end

def new_response_environment(servlet_response = servlet_response)
def new_response_environment(servlet_response)
org.jruby.rack.RackResponseEnvironment.impl do |name, *args|
servlet_response.send(name, *args)
end
Expand Down
6 changes: 3 additions & 3 deletions src/spec/ruby/rack/jms_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

require File.expand_path('spec_helper', File.dirname(__FILE__) + '/..')

import org.jruby.rack.jms.QueueContextListener
import org.jruby.rack.jms.QueueManager
import org.jruby.rack.jms.DefaultQueueManager
java_import org.jruby.rack.jms.QueueContextListener
java_import org.jruby.rack.jms.QueueManager
java_import org.jruby.rack.jms.DefaultQueueManager

describe QueueContextListener do
before :each do
Expand Down
Binary file removed vendor/gems/bouncy-castle-java-1.5.0147.gem
Binary file not shown.
Binary file removed vendor/gems/jruby-openssl-0.9.4.gem
Binary file not shown.

0 comments on commit 15edd63

Please sign in to comment.