Skip to content

Commit

Permalink
Showing 7 changed files with 160 additions and 138 deletions.
186 changes: 83 additions & 103 deletions antlib/extra.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
<project basedir='..'>
<target name='test-jruby-complete-jar'>
<target name='mvn'>
<exec executable='mvn'>
<arg line='-q'/>
<arg line='-Pmain,complete'/>
</exec>
</target>
<target name='test-jruby-jars-jruby.1.9' depends='mvn'>
<exec executable='java' failonerror='true'>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.17-SNAPSHOT.jar'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.17-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='lib/ruby/gems/shared/gems/rake-10.1.0/lib/rake/rake_test_loader.rb'/>
<arg value='test/test_globals.rb'/>
<arg value='test/test_argf.rb'/>
@@ -107,112 +113,86 @@
<arg value='-v'/>
</exec>
</target>
<target name='test-jruby-core-stdlib-jars'>
<target name='test-jruby-complete-slow' depends='mvn'>
<exec executable='java' failonerror='true'>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.17-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='lib/ruby/gems/shared/gems/rake-10.1.0/lib/rake/rake_test_loader.rb'/>
<arg value='test/test_command_line_switches.rb'/>
<arg value='test/test_launching_by_shell_script.rb'/>
<arg value='-v'/>
</exec>
</target>
<target name='test-jruby-jars-objectspace' depends='mvn'>
<exec executable='java' failonerror='true'>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-1.7.17-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='lib/ruby/gems/shared/gems/rake-10.1.0/lib/rake/rake_test_loader.rb'/>
<arg value='test/test_globals.rb'/>
<arg value='test/test_argf.rb'/>
<arg value='test/test_array.rb'/>
<arg value='test/test_autoload.rb'/>
<arg value='test/test_backquote.rb'/>
<arg value='test/test_backtraces.rb'/>
<arg value='test/test_big_decimal.rb'/>
<arg value='test/test_binding_eval_yield.rb'/>
<arg value='test/test_caller.rb'/>
<arg value='test/test_case.rb'/>
<arg value='test/test_class.rb'/>
<arg value='test/test_comparable.rb'/>
<arg value='test/test_core_arities.rb'/>
<arg value='test/test_custom_enumerable.rb'/>
<arg value='test/test_cvars_in_odd_scopes.rb'/>
<arg value='test/test_date_joda_time.rb'/>
<arg value='test/test_defined.rb'/>
<arg value='test/test_default_constants.rb'/>
<arg value='test/test_delegated_array_equals.rb'/>
<arg value='test/test_dir.rb'/>
<arg value='test/test_dir_with_jar_without_dir_entry.rb'/>
<arg value='test/test_digest_extend.rb'/>
<arg value='test/test_digest2.rb'/>
<arg value='test/test_env.rb'/>
<arg value='test/test_etc.rb'/>
<arg value='test/test_file.rb'/>
<arg value='test/test_flip.rb'/>
<arg value='test/test_frame_self.rb'/>
<arg value='test/test_hash.rb'/>
<arg value='test/test_higher_javasupport.rb'/>
<arg value='test/test_included_in_object_space.rb'/>
<arg value='test/test_integer_overflows.rb'/>
<arg value='test/test_ivar_table_integrity.rb'/>
<arg value='test/test_io.rb'/>
<arg value='test/test_load.rb'/>
<arg value='test/test_method.rb'/>
<arg value='test/test_method_cache.rb'/>
<arg value='test/test_method_override_and_caching.rb'/>
<arg value='test/test_java_accessible_object.rb'/>
<arg value='test/test_java_extension.rb'/>
<arg value='test/test_java_wrapper_deadlock.rb'/>
<arg value='test/test_jruby_internals.rb'/>
<arg value='test/compiler/test_jrubyc.rb'/>
<arg value='test/test_marshal_with_instance_variables.rb'/>
<arg value='test/test_marshal_gemspec.rb'/>
<arg value='test/test_method_missing.rb'/>
<arg value='test/test_no_stack_trace_stomp.rb'/>
<arg value='test/test_pack.rb'/>
<arg value='test/test_primitive_to_java.rb'/>
<arg value='test/test_process.rb'/>
<arg value='test/test_proc_visibility.rb'/>
<arg value='test/test_parsing.rb'/>
<arg value='test/test_pathname.rb'/>
<arg value='test/test_random.rb'/>
<arg value='test/test_rbconfig.rb'/>
<arg value='test/test_require_once.rb'/>
<arg value='test/test_respond_to.rb'/>
<arg value='test/test_socket.rb'/>
<arg value='test/test_string_java_bytes.rb'/>
<arg value='test/test_string_printf.rb'/>
<arg value='test/test_string_to_number.rb'/>
<arg value='test/test_super_call_site_caching.rb'/>
<arg value='test/test_system.rb'/>
<arg value='test/test_system_error.rb'/>
<arg value='test/test_timeout.rb'/>
<arg value='test/test_thread.rb'/>
<arg value='test/test_threaded_nonlocal_return.rb'/>
<arg value='test/test_time_add.rb'/>
<arg value='test/test_time_nil_ops.rb'/>
<arg value='test/test_time_tz.rb'/>
<arg value='test/test_unmarshal.rb'/>
<arg value='test/test_vietnamese_charset.rb'/>
<arg value='test/test_win32.rb'/>
<arg value='test/test_zlib.rb'/>
<arg value='test/test_loading_builtin_libraries.rb'/>
<arg value='test/test_load_compiled_ruby_class_from_classpath.rb'/>
<arg value='test/test_null_channel.rb'/>
<arg value='test/test_irubyobject_java_passing.rb'/>
<arg value='test/test_jruby_object_input_stream.rb'/>
<arg value='test/test_jar_on_load_path.rb'/>
<arg value='test/test_jruby_ext.rb'/>
<arg value='test/test_jruby_core_ext.rb'/>
<arg value='test/test_thread_context_frame_dereferences_unreachable_variables.rb'/>
<arg value='test/test_context_classloader.rb'/>
<arg value='test/test_rexml_document.rb'/>
<arg value='test/test_load_compiled_ruby.rb'/>
<arg value='test/test_openssl_stub.rb'/>
<arg value='test/test_missing_jruby_home.rb'/>
<arg value='test/test_ast_inspector.rb'/>
<arg value='test/test_jarred_gems_with_spaces_in_directory.rb'/>
<arg value='test/test_kernel.rb'/>
<arg value='test/test_dir_with_plusses.rb'/>
<arg value='test/test_jar_file.rb'/>
<arg value='test/test_jruby_synchronized.rb'/>
<arg value='test/test_instantiating_interfaces.rb'/>
<arg value='test/test_openssl.rb'/>
<arg value='test/test_tempfile_cleanup.rb'/>
<arg value='test/test_objectspace.rb'/>
<arg value='test/test_cache_map_leak.rb'/>
<arg value='-v'/>
</exec>
</target>
<target name='test-jruby-complete-rubicon.1.9' depends='mvn'>
<exec executable='java' failonerror='true'>
<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>
<arg value='-cp'/>
<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-1.7.17-SNAPSHOT.jar'/>
<arg value='org.jruby.Main'/>
<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>
<arg value='lib/ruby/gems/shared/gems/rake-10.1.0/lib/rake/rake_test_loader.rb'/>
<arg value='test/rubicon/test_access_control.rb'/>
<arg value='test/rubicon/test_array.rb'/>
<arg value='test/rubicon/test_assignment.rb'/>
<arg value='test/rubicon/test_basic_expressions.rb'/>
<arg value='test/rubicon/test_bignum.rb'/>
<arg value='test/rubicon/test_blocks_procs.rb'/>
<arg value='test/rubicon/test_boolean_expressions.rb'/>
<arg value='test/rubicon/test_case.rb'/>
<arg value='test/rubicon/test_catch_throw.rb'/>
<arg value='test/rubicon/test_class.rb'/>
<arg value='test/rubicon/test_comparable.rb'/>
<arg value='test/rubicon/test_constants.rb'/>
<arg value='test/rubicon/test_enumerable.rb'/>
<arg value='test/rubicon/test_eval.rb'/>
<arg value='test/rubicon/test_exception.rb'/>
<arg value='test/rubicon/test_exceptions.rb'/>
<arg value='test/rubicon/test_false_class.rb'/>
<arg value='test/rubicon/test_float.rb'/>
<arg value='test/rubicon/test_floats.rb'/>
<arg value='test/rubicon/test_hash.rb'/>
<arg value='test/rubicon/test_if_unless.rb'/>
<arg value='test/rubicon/test_integer.rb'/>
<arg value='test/rubicon/test_io.rb'/>
<arg value='test/rubicon/test_loop_stuff.rb'/>
<arg value='test/rubicon/test_marshal.rb'/>
<arg value='test/rubicon/test_match_data.rb'/>
<arg value='test/rubicon/test_math.rb'/>
<arg value='test/rubicon/test_method.rb'/>
<arg value='test/rubicon/test_methods.rb'/>
<arg value='test/rubicon/test_module.rb'/>
<arg value='test/rubicon/test_module_private.rb'/>
<arg value='test/rubicon/test_nil_class.rb'/>
<arg value='test/rubicon/test_numeric.rb'/>
<arg value='test/rubicon/test_object.rb'/>
<arg value='test/rubicon/test_object_space.rb'/>
<arg value='test/rubicon/test_pack.rb'/>
<arg value='test/rubicon/test_proc.rb'/>
<arg value='test/rubicon/test_regexp.rb'/>
<arg value='test/rubicon/test_range.rb'/>
<arg value='test/rubicon/test_string.rb'/>
<arg value='test/rubicon/test_strings.rb'/>
<arg value='test/rubicon/test_struct.rb'/>
<arg value='test/rubicon/test_symbol.rb'/>
<arg value='test/rubicon/test_thread_group.rb'/>
<arg value='test/rubicon/test_true_class.rb'/>
<arg value='-v'/>
</exec>
</target>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='test-jruby-complete-jar,test-jruby-core-stdlib-jars'/></project>
<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='test-jruby-jars-jruby.1.9,test-jruby-complete-slow,test-jruby-jars-objectspace,test-jruby-complete-rubicon.1.9'/></project>
62 changes: 45 additions & 17 deletions test/pom.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,41 @@
project 'JRuby Integration Tests' do
class TargetBuilder
attr_reader :targets
def initialize( version, basedir )
@version = version
@basedir = basedir
@names = ""
@targets = ""
@rake = Dir[File.join(@basedir, "../lib/ruby/gems/shared/gems/rake-*/lib/rake/rake_test_loader.rb")].first.sub( /.*\/..\/lib\//, 'lib/' )
end
def names
@names[0..-2]
end
def create_target( name, complete )
files = ""
File.open(File.join(@basedir, name + '.index')) do |f|
f.each_line.each do |line|
filename = "#{@basedir}/#{line.chomp}.rb"
next unless File.exist? filename
filename.sub!( /.*\/test\//, 'test/' )
files << "<arg value='#{filename}'/>\n"
end
end

if complete
name = "test-jruby-complete-#{name}"
jars = "maven/jruby-complete/target/jruby-complete-#{@version}.jar"
else
name = "test-jruby-jars-#{name}"
jars = "lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-#{@version}.jar"
end
@names << name + ","
#
@targets << "<target name='#{name}' depends='mvn'>\n<exec executable='java' failonerror='true'>\n<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>\n<arg value='-cp'/>\n<arg value='core/target/test-classes:test/target/test-classes:#{jars}'/>\n<arg value='org.jruby.Main'/>\n<arg value='-I.:test/externals/ruby1.9:test/externals/ruby1.9/ruby'/>\n<arg value='#{@rake}'/>\n#{files}<arg value='-v'/>\n</exec>\n</target>\n"
end
end

project 'JRuby Integration Tests' do

version = File.read( File.join( basedir, '..', 'VERSION' ) ).strip

model_version '4.0.0'
@@ -101,21 +137,13 @@
test_source_directory '.'
end


rake = Dir[File.join(basedir, "../lib/ruby/gems/shared/gems/rake-*/lib/rake/rake_test_loader.rb")].first.sub( /.*\/..\/lib\//, 'lib/' )
files = ""
File.open(File.join(basedir, 'jruby.1.9.index')) do |f|
f.each_line.each do |line|
filename = "#{basedir}/#{line.chomp}.rb"
next unless File.exist? filename
filename.sub!( /.*\/test\//, 'test/' )
files << "<arg value='#{filename}'/>\n"
end
end

target1 = "<target name='test-jruby-complete-jar'>\n<exec executable='java' failonerror='true'>\n<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>\n<arg value='-cp'/>\n<arg value='core/target/test-classes:test/target/test-classes:maven/jruby-complete/target/jruby-complete-#{version}.jar'/>\n<arg value='org.jruby.Main'/>\n<arg value='-I.'/>\n<arg value='#{rake}'/>\n#{files}<arg value='-v'/>\n</exec>\n</target>\n"
target2 = "<target name='test-jruby-core-stdlib-jars'>\n<exec executable='java' failonerror='true'>\n<arg value='-Djruby.home=uri:classloader://META-INF/jruby.home'/>\n<arg value='-cp'/>\n<arg value='core/target/test-classes:test/target/test-classes:lib/jruby.jar:maven/jruby-stdlib/target/jruby-stdlib-#{version}.jar'/>\n<arg value='org.jruby.Main'/>\n<arg value='-I.'/>\n<arg value='#{rake}'/>\n#{files}<arg value='-v'/>\n</exec>\n</target>\n"

File.write(File.join(basedir, '..', 'antlib', 'extra.xml'), "<project basedir='..'>\n#{target1}#{target2}<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='test-jruby-complete-jar,test-jruby-core-stdlib-jars'/></project>")
builder = TargetBuilder.new( version, basedir )
builder.create_target( 'jruby.1.9', false )
builder.create_target( 'slow', true )
builder.create_target( 'objectspace', false )
#TODO builder.create_target( 'mri.1.9', false )
builder.create_target( 'rubicon.1.9', true )

File.write(File.join(basedir, '..', 'antlib', 'extra.xml'), "<project basedir='..'>\n<target name='mvn'>\n<exec executable='mvn'>\n<arg line='-q'/>\n<arg line='-Pmain,complete'/>\n</exec>\n</target>\n#{builder.targets}<target description='test using jruby-complete or jruby-core/jruby-stdlib jars' name='test-jruby-jars' depends='#{builder.names}'/></project>")

end
16 changes: 10 additions & 6 deletions test/rubicon/test_object_space.rb
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
require 'test/unit'
require 'test/test_helper'
require 'tempfile'
require 'rbconfig'
require 'jruby'

#
# Find the name of the interpreter.
# FIXME: This should be moved to a common location.
WINDOWS = RbConfig::CONFIG['host_os'] =~ /Windows|mswin/
SEPARATOR = WINDOWS ? '\\' : '/'
bin = RbConfig::CONFIG['bindir'].gsub('/', SEPARATOR)
$interpreter = [bin, RbConfig::CONFIG['ruby_install_name']].join(SEPARATOR)
#WINDOWS = RbConfig::CONFIG['host_os'] =~ /Windows|mswin/
#SEPARATOR = WINDOWS ? '\\' : '/'
#bin = RbConfig::CONFIG['bindir'].gsub('/', SEPARATOR)
#$interpreter = [bin, RbConfig::CONFIG['ruby_install_name']].join(SEPARATOR)

class TestObjectSpace < Test::Unit::TestCase
include TestHelper

#
# Check that two arrays contain the same "bag" of elements.
@@ -42,6 +44,7 @@ def assert_bag_equal(expected, actual)
end

def test_s__id2ref
skip("object space is not enabled") unless JRuby.runtime.object_space_enabled?
s = "hello"
t = ObjectSpace._id2ref(s.__id__)
assert_equal(s, t)
@@ -59,9 +62,9 @@ def test_s_finalizers
}
tf.close
if ENV['OS'] =~ /\AWin/
command = %{#$interpreter "#{tf.path}"}
command = %{#{interpreter} "#{tf.path}"}
else
command = %{#$interpreter #{tf.path}}
command = %{#{interpreter} #{tf.path}}
end
IO.popen(command) do |p|
assert_equal("OK", p.gets.chomp)
@@ -77,6 +80,7 @@ class C < A; end
class D < C; end

def test_s_each_object
skip("object space is not enabled") unless JRuby.runtime.object_space_enabled?
a = A.new
b = B.new
c = C.new
4 changes: 3 additions & 1 deletion test/test_cache_map_leak.rb
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@ class TestMe; end

class TestCacheMapLeak < Test::Unit::TestCase

def setup
def setup_test
@num = 100
@num.times { class << TestMe.new; def foo; end; end }

@@ -14,6 +14,8 @@ def setup
end

def test_objects_are_released_by_cache_map
skip("object space is not enabled") unless JRuby.runtime.object_space_enabled?
setup_test
assert(@num != ObjectSpace.each_object(TestMe){}, "Objects not being release by CacheMap" )
end

2 changes: 2 additions & 0 deletions test/test_command_line_switches.rb
Original file line number Diff line number Diff line change
@@ -252,6 +252,7 @@ def test_dash_dash_version_shows_version
if java.lang.System.get_property('java.vm.name') =~ /HotSpot/
# JRUBY-2648 [Note: jre6 on windows does not ship server VM - use jdk]
def test_server_vm_option
skip("test needs fix for jruby-complete.jar") if IS_JAR_EXECUTION
# server VM when explicitly set --server
result = jruby(%Q{--server -rjava \
-e "print java.lang.management.ManagementFactory.getCompilationMXBean.name"})
@@ -407,6 +408,7 @@ def test_rubyopts_is_not_used_to_set_the_script
end

def test_inproc_execute_with_globs
skip("test needs fix for jruby-complete.jar") if IS_JAR_EXECUTION
args = %{-Xlaunch.inproc=true -e 'system %{jruby -e "p ARGV.sort" test/dir{1,2}/target*}'}
assert_equal %{["test/dir1/target.rb", "test/dir2/target.class"]\n}, jruby(args)
end
20 changes: 12 additions & 8 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
@@ -39,19 +39,23 @@ def q
WINDOWS ? '"' : '\''
end

def interpreter( options = {} )
options = options.collect { |k,v| "-D#{k}=\"#{v}\"" }
if RUBY =~ /-cp /
RUBY.sub(/-cp [.]/, "-cp #{ENV["CLASSPATH"]}").sub(/-cp /, options.join(' ') + ' -cp ')
else
RUBY
end
end

def jruby(*args)
options = []
if args.last.is_a? Hash
options = args.last.collect { |k,v| "-D#{k}=\"#{v}\"" }
options = args.last
args = args[0..-2]
end
if RUBY =~ /-cp /
ruby = RUBY.sub(/-cp [.]/, "-cp #{ENV["CLASSPATH"]}").sub(/-cp /, options.join(' ') + ' -cp ')
else
options.each { |a| args.unshift "-J#{a}" }
ruby = RUBY
end
with_jruby_shell_spawning { `#{ruby} #{args.join(' ')}` }
options.each { |k,v| args.unshift "-J-D#{k}=\"#{v}\"" } unless RUBY =~ /-cp /
with_jruby_shell_spawning { `#{interpreter(options)} #{args.join(' ')}` }
end

def jruby_with_pipe(pipe, *args)
8 changes: 5 additions & 3 deletions test/test_launching_by_shell_script.rb
Original file line number Diff line number Diff line change
@@ -79,7 +79,7 @@ def test_system_call_with_stdin_data_doesnt_hang
if (!WINDOWS)
# JRUBY-2295
def test_java_props_with_spaces
res = jruby(%q{-J-Dfoo='a b c' -e "require 'java'; puts java.lang.System.getProperty('foo')"}).chomp
res = jruby(%q{-e "require 'java'; puts java.lang.System.getProperty('foo')"}, 'foo' => 'a b c').chomp
assert_equal("a b c", res)
end

@@ -180,7 +180,9 @@ def test_run_script_from_jar
end

def test_launch_inproc_ignores_dash_J_with_warning
output = `#{ENV_JAVA['jruby.home']}/bin/jruby -J-Xmx256m -e "puts true"`
assert_equal "true\n", output
unless IS_JAR_EXECUTION
output = `#{ENV_JAVA['jruby.home']}/bin/jruby -J-Xmx256m -e "puts true"`
assert_equal "true\n", output
end
end
end

0 comments on commit 968a634

Please sign in to comment.