2 require 'test/test_helper'
5 class TestProcess < Test::Unit::TestCase
9 @shell = Config::CONFIG['SHELL']
10 @shellcmd = "#@shell " + (Config::CONFIG['host_os'] =~ /Windows|mswin/ ? "/c" : "-c")
11 system(%{#@shellcmd "exit 1"})
13 system(%{#@shellcmd "exit 2"})
17 def test_process_status_returned_from_dollar_query
18 assert_kind_of Process::Status, @first_status
19 assert_kind_of Process::Status, @second_status
22 def test_process_status_to_i
23 assert_equal 256, @first_status.to_i
24 assert_equal 512, @second_status.to_i
27 def test_process_status_to_s
28 assert_equal "256", @first_status.to_s
29 assert_equal "512", @second_status.to_s
32 def test_process_status_exitstatus
33 assert_equal 1, @first_status.exitstatus
34 assert_equal 2, @second_status.exitstatus
37 def test_process_times
39 assert_nothing_raised {
50 unless Config::CONFIG['host_os'] =~ /Windows|mswin/ || !File.exist?("bin/jruby")
51 assert_equal "1", %x{sh -c 'bin/jruby -e "exit 1" ; echo $?'}.strip
57 def test_not_implemented_methods_on_windows
58 # The goal here is to make sure that those "weird"
59 # POSIX methods don't break JRuby, since there were
60 # numerous regressions in this area.
61 assert_raise(NotImplementedError) { Process.uid = 5 }
62 assert_raise(NotImplementedError) { Process.gid }
63 assert_raise(NotImplementedError) { Process.gid = 5 }
65 # TODO: JRUBY-2705, doesn't work on x64 JVM
66 assert_equal 0, Process.euid unless WINDOWS_JVM_64
68 assert_raise(NotImplementedError) { Process.euid = 5 }
69 assert_raise(NotImplementedError) { Process.egid }
70 assert_raise(NotImplementedError) { Process.egid = 5 }
71 assert_raise(NotImplementedError) { Process.getpgid(100) }
72 assert_raise(NotImplementedError) { Process.setpgid(100, 555) }
73 assert_raise(NotImplementedError) { Process.setpriority(100, 100, 100) }
74 assert_raise(NotImplementedError) { Process.getpriority(100, 100) }
75 assert_raise(NotImplementedError) { Process.setrlimit(100, 100) }
76 assert_raise(NotImplementedError) { Process.getrlimit(100) }
77 assert_raise(NotImplementedError) { Process.groups }
78 assert_raise(NotImplementedError) { Process.groups = [] }
79 assert_raise(NotImplementedError) { Process.maxgroups }
80 assert_raise(NotImplementedError) { Process.maxgroups = 100 }
81 assert_raise(NotImplementedError) { Process.initgroups(100, 100) }
83 # TODO: JRUBY-2639, doesn't work on x64 JVM
84 assert_equal 0, Process.ppid unless WINDOWS_JVM_64
86 # TODO: temporal (JRUBY-2353)
87 assert_raise(NotImplementedError) { Process.kill(100, 100) }
89 # TODO: temporal (JRUBY-2354)
90 assert_raise(NotImplementedError) { Process.wait }
91 assert_raise(NotImplementedError) { Process.wait2 }
92 assert_raise(NotImplementedError) { Process.waitpid }
93 assert_raise(NotImplementedError) { Process.waitpid2 }
94 assert_raise(NotImplementedError) { Process.waitall }