Fix some symbol.to_proc problems
[jruby.git] / test / test_launching_by_shell_script.rb
blobc4065432399bbfba708d6305c883907ef45f3701
1 require 'test/unit'
2 require 'test/test_helper'
4 class TestLaunchingByShellScript < Test::Unit::TestCase
5   include TestHelper
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(' ')}`
11    ensure
12     JRuby.runtime.instance_config.run_ruby_in_process = prev_in_process
13   end
15   def test_minus_e
16     assert_equal "true", jruby('-e "puts true"').chomp
17     assert_equal 0, $?.exitstatus
18   end
20   def test_launch_script
21     jruby "test/fib.rb"
22     assert_equal 0, $?.exitstatus
23   end
25   if WINDOWS
26     def test_system_call_without_stdin_data_doesnt_hang
27       out = jruby(%q{-e "system 'dir test'"})
28       assert(out =~ /fib.rb/)
29     end
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/)
34     end
35   else
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)
39     end
40   end
42   if (!WINDOWS)
43     # JRUBY-2295
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)
47     end
48   end
50   def test_at_exit
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
55   end
56 end