2 require 'test/test_helper'
4 class TestLaunchingByShellScript < Test::Unit::TestCase
7 def jruby_with_pipe(pipe, *args)
8 prev_in_process = JRuby.runtime.instance_config.run_ruby_in_process
9 JRuby.runtime.instance_config.run_ruby_in_process = false
10 `#{pipe} | "#{RUBY}" #{args.join(' ')}`
12 JRuby.runtime.instance_config.run_ruby_in_process = prev_in_process
16 assert_equal "true", jruby('-e "puts true"').chomp
17 assert_equal 0, $?.exitstatus
20 def test_launch_script
22 assert_equal 0, $?.exitstatus
26 def test_system_call_without_stdin_data_doesnt_hang
27 out = jruby(%q{-e "system 'dir test'"})
28 assert(out =~ /fib.rb/)
31 def test_system_call_with_stdin_data_doesnt_hang_on_windows
32 out = jruby_with_pipe("echo echo 'one_two_three_test'", %q{-e "system 'cmd'"})
33 assert(out =~ /one_two_three_test/)
36 def test_system_call_with_stdin_data_doesnt_hang
37 out = jruby_with_pipe("echo 'vvs'", %q{-e "system 'cat'"})
38 assert_equal("vvs\n", out)
44 def test_java_props_with_spaces
45 res = jruby(%q{-J-Dfoo='a b c' -e "require 'java'; puts java.lang.System.getProperty('foo')"}).chomp
46 assert_equal("a b c", res)
51 assert_equal "", jruby("-e 'at_exit { exit 0 }'").chomp
52 assert_equal 0, $?.exitstatus
53 assert_equal "", jruby("-e 'at_exit { exit 1 }'").chomp
54 assert_equal 1, $?.exitstatus