summaryrefslogtreecommitdiff
path: root/dev-ruby/eventmachine/files/eventmachine-1.2.7-test-processes.patch
blob: 51e2a48c6f558a3118ffa0c300e84823d5e29d60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
From ec27b6250c2a00b4f2720abd86669e194ca016ac Mon Sep 17 00:00:00 2001
From: MSP-Greg <Greg.mpls@gmail.com>
Date: Fri, 21 May 2021 11:24:15 -0500
Subject: [PATCH] Update test_processes.rb

---
 tests/test_processes.rb | 35 +++++++++++++++++++++++++++--------
 1 file changed, 27 insertions(+), 8 deletions(-)

diff --git a/tests/test_processes.rb b/tests/test_processes.rb
index eb21a6cec..9546022e7 100644
--- a/tests/test_processes.rb
+++ b/tests/test_processes.rb
@@ -32,23 +32,42 @@ def setup
     end
 
     def test_em_system
+      out, status = nil, nil
+
       EM.run{
-        EM.system('ls'){ |out,status| $out, $status = out, status; EM.stop }
+        EM.system('ls'){ |_out,_status| out, status = _out, _status; EM.stop }
       }
 
-      assert( $out.length > 0 )
-      assert_equal(0, $status.exitstatus)
-      assert_kind_of(Process::Status, $status)
+      assert(out.length > 0 )
+      assert_kind_of(Process::Status, status)
+      assert_equal(0, status.exitstatus)
+    end
+
+    def test_em_system_bad_exitstatus
+      status = nil
+      sys_pid = nil
+
+      EM.run{
+        sys_pid = EM.system('exit 1'){ |_out,_status| status = _status; EM.stop }
+      }
+
+      assert_kind_of(Process::Status, status)
+      refute_equal(0, status.exitstatus)
+      assert_equal sys_pid, status.pid
     end
 
     def test_em_system_pid
-      $pids = []
+      status = nil
+      sys_pid = nil
 
       EM.run{
-        $pids << EM.system('echo hi', proc{ |out,status|$pids << status.pid; EM.stop })
+        sys_pid = EM.system('echo hi', proc{ |_out,_status| status = _status; EM.stop })
       }
 
-      assert_equal $pids[0], $pids[1]
+      refute_equal(0, sys_pid)
+      assert_kind_of(Process::Status, status)
+      refute_equal(0, status.pid)
+      assert_equal sys_pid, status.pid
     end
 
     def test_em_system_with_proc
@@ -57,8 +76,8 @@ def test_em_system_with_proc
       }
 
       assert( $out.length > 0 )
-      assert_equal(0, $status.exitstatus)
       assert_kind_of(Process::Status, $status)
+      assert_equal(0, $status.exitstatus)
     end
 
     def test_em_system_with_two_procs