Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 3ae0ad8630fc
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: e32c52d6a8b5
Choose a head ref
  • 3 commits
  • 4 files changed
  • 1 contributor

Commits on Jun 10, 2017

  1. Copy the full SHA
    d59078b View commit details
  2. Copy the full SHA
    0816318 View commit details
  3. Copy the full SHA
    e32c52d View commit details
Showing with 54 additions and 47 deletions.
  1. +2 −2 .travis.yml
  2. +43 −39 test/jruby/test_jar_complete.rb
  3. +7 −6 test/pom.rb
  4. +2 −0 test/slow.index
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -76,8 +76,8 @@ matrix:
- env: COMMAND=test/check_versions.sh
jdk: oraclejdk8
allow_failures:
- env: PHASE='-Pj2ee'
jdk: oraclejdk7
#- env: PHASE='-Pj2ee'
# jdk: oraclejdk7
# NOTE: build seems to never start (waited for any to finish for more than a day) - probably a travis-ci bug
#- env: PHASE='-Pmain'
# sudo: required
82 changes: 43 additions & 39 deletions test/jruby/test_jar_complete.rb
Original file line number Diff line number Diff line change
@@ -1,31 +1,36 @@
# This gets run from 'ant test-jar-complete' which ensures that a
# complete jar is built first.

# Make sure we're not affected by RVM or other gem envvars
ENV.delete 'GEM_HOME'
ENV.delete 'GEM_PATH'
# gets run from 'mvn -P jruby_complete_jar_extended' which ensures that a complete jar is built first

require 'test/unit'
require 'rbconfig'
require 'fileutils'
require 'pathname'

prefix = RbConfig::CONFIG['prefix']
abort "error: test must be launched from complete jar (found prefix = #{prefix})" unless prefix =~ %r{^file.*!/META-INF/jruby\.home}
def file_from_url(path)
if RbConfig::CONFIG['host_os'] =~ /Windows|mswin/
path[%r{^file:\/*?([a-zA-Z]:/[^!]+)}, 1]
else
path[%r{^file:\/*?(/[^!]+)}, 1]
end
end
COMPLETE_JAR = file_from_url prefix
abort "error: could not figure out complete jar from RbConfig::CONFIG['prefix'] (#{prefix})" unless COMPLETE_JAR

puts "Using jar: #{COMPLETE_JAR}"
complete_jar = ( prefix =~ %r{^uri:classloader:.*?META-INF/jruby\.home} )

class JarCompleteTest < Test::Unit::TestCase
include FileUtils

# Make sure we're not affected by RVM or other gem envvars
ENV.delete 'GEM_HOME'
ENV.delete 'GEM_PATH'

@@windows = RbConfig::CONFIG['host_os'] =~ /Windows|mswin/

def file_from_url(path)
if @@windows
path[%r{^(:?uri:classloader):\/*?([a-zA-Z]:/[^!]+)}, 1]
else
path[%r{^(:?uri:classloader):\/*?(/[^!]+)}, 1]
end
end

COMPLETE_JAR = ENV_JAVA["java.class.path"].split(File::PATH_SEPARATOR).find { |path| path =~ /jruby-complete-.*?\.jar/ }

abort "error: could not figure out complete jar from 'java.class.path' (#{ENV_JAVA["java.class.path"]})" unless COMPLETE_JAR
puts "Using jar: #{COMPLETE_JAR}"


TMP_DIR = begin
# Try not to use default $TMPDIR on OS X which contains +++
tmp = [ENV['TEMP'], ENV['TMPDIR'], '/tmp', '/var/tmp'].detect {|d| d && d !~ /[ +]/ && File.directory?(d)}
@@ -64,7 +69,8 @@ def test_complete_jar
end

def test_rubygems_home
assert jruby_complete("-rubygems -e 'puts Gem.dir'").chomp =~ /#{COMPLETE_JAR}/
gem_dir = jruby_complete("-rubygems -e 'puts Gem.dir'").chomp
assert_equal 'uri:classloader:/META-INF/jruby.home/lib/ruby/gems/shared', gem_dir
end

def test_contains_rake_gem
@@ -78,38 +84,33 @@ def test_rake_help_works
end

def test_prefix_in_path_with_spaces
tmp = File.join(TMP_DIR, "hi there")
mkdir_p tmp
mkdir_p tmp = File.join(TMP_DIR, "hi there")
complete_jar = File.expand_path(File.join(tmp, 'jruby-complete.jar'))
cp COMPLETE_JAR, complete_jar
output = jruby_complete(complete_jar, "-rrbconfig -e 'puts RbConfig::CONFIG[%{prefix}]'").chomp
file = file_from_url(output)
assert File.exists?(file)
assert_equal complete_jar, file
output = jruby_complete(complete_jar, "-rrbconfig -e 'puts RbConfig::CONFIG[%{prefix}];'").chomp
assert_equal 'uri:classloader://META-INF/jruby.home', output
end

def test_prefix_in_path_with_pluses
tmp = File.join(TMP_DIR, "hi+there")
mkdir_p tmp
mkdir_p tmp = File.join(TMP_DIR, "hi+there")
complete_jar = File.expand_path(File.join(tmp, 'jruby-complete.jar'))
cp COMPLETE_JAR, complete_jar
output = jruby_complete(complete_jar, "-rrbconfig -e 'puts RbConfig::CONFIG[%{prefix}]'").chomp
file = file_from_url(output)
assert File.exists?(file)
assert_equal complete_jar, file
#file = file_from_url(output)
#assert File.exists?(file), "file: #{file} (from #{output.inspect}) does not exist"
assert_equal 'uri:classloader://META-INF/jruby.home', output
end

# JRUBY-5337
def test_script_with__FILE__constant_in_jar_with_spaces
tmp = File.join(TMP_DIR, "hi there")
mkdir_p tmp
mkdir_p tmp = File.join(TMP_DIR, "hi there")
complete_jar = File.expand_path(File.join(tmp, 'jruby-complete.jar'))
cp COMPLETE_JAR, complete_jar
script = File.join(TMP_DIR, "_file_constant_.rb")
File.open(script, "wb") {|f| f.puts "puts __FILE__" }
script = File.join(TMP_DIR, '_file_constant_.rb')
File.open(script, 'wb') {|f| f.puts "puts __FILE__" }
Dir.chdir(File.dirname(script)) { system %{jar uf "#{complete_jar}" #{File.basename(script)}} }
output = jruby_complete(complete_jar, %{-e "require '_file_constant_'"}).chomp
assert output =~ /#{tmp}/, "'#{output}' does not match '#{tmp}'"
assert_match /uri:classloader\:\/_file_constant_\.rb/, output
end

def test_binscripts_can_be_run_from_classpath
@@ -119,10 +120,13 @@ def test_binscripts_can_be_run_from_classpath
end

def test_relative_require_from_gem_on_classpath
relative_require_gem = File.expand_path(File.join(File.dirname(__FILE__), "..", "samples", "relative_require.jar"))
relative_require_jar = File.expand_path('samples/relative_require.jar', File.join(File.dirname(__FILE__), '../..'))

`java -cp \"#{COMPLETE_JAR}:#{relative_require_gem}\" org.jruby.Main -rrelative_require -e "puts RelativeRequire::VERSION"`
`java -cp \"#{COMPLETE_JAR}:#{relative_require_jar}\" org.jruby.Main -rrelative_require -e "puts RelativeRequire::VERSION"`

assert $? == 0
assert $? == 0, "`java -cp ... org.jruby.Main -rrelative_require returned: #{$?.inspect}"
end
end

end if complete_jar

warn "#{__FILE__} must be launched from complete jar (found prefix = #{prefix})" unless complete_jar
13 changes: 7 additions & 6 deletions test/pom.rb
Original file line number Diff line number Diff line change
@@ -138,11 +138,11 @@
jar 'org.jruby:jruby-complete', '${project.version}', :scope => :provided

plugin :antrun do
[ 'jruby','objectspace', 'slow' ].each do |index|
files = ""
File.open(File.join(basedir, index + '.index')) do |f|
f.each_line.each do |line|
next if line =~ /^#/ or line.strip.empty?
[ 'jruby', 'objectspace', 'slow' ].each do |index|
files = []
File.open(File.join(basedir, index + '.index')) do |file|
file.each_line do |line|
next if line =~ /^#/ || line.strip.empty?
filename = "mri/#{line.chomp}"
filename = "jruby/#{line.chomp}.rb" unless File.exist? File.join(basedir, filename)
filename = "#{line.chomp}.rb" unless File.exist? File.join(basedir, filename)
@@ -152,9 +152,10 @@
files << "<arg value='test/#{filename}'/>"
end
end
files = files.join('')

execute_goals( 'run',
:id => 'jruby_complete_jar_' + index,
:id => "jruby_complete_jar_#{index}",
:phase => 'test',
:configuration => [ xml( "<target><exec dir='${jruby.home}' executable='java' failonerror='true'><arg value='-cp'/><arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-${project.version}.jar'/><arg value='-Djruby.aot.loadClasses=true'/><arg value='org.jruby.Main'/><arg value='-I.'/><arg value='-Itest/mri/ruby'/><arg value='-Itest/mri'/><arg value='-Itest'/><arg value='-rtest/mri_test_env'/><arg value='lib/ruby/stdlib/rake/rake_test_loader.rb'/>#{files}<arg value='-v'/></exec></target>" ) ] )
end
2 changes: 2 additions & 0 deletions test/slow.index
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
jruby/test_command_line_switches
jruby/test_launching_by_shell_script
jruby/test_ffi_pointer_leak
# only run when executed with jruby-complete.jar (jruby_complete_jar_extended profile)
jruby/test_jar_complete