File tree 2 files changed +13
-17
lines changed
2 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -27,12 +27,8 @@ describe Process::Status do
27
27
Process ::Status .new(exit_status(128 )).exit_code.should eq 128
28
28
Process ::Status .new(exit_status(255 )).exit_code.should eq 255
29
29
30
- if {{ flag?(:unix ) }}
31
- expect_raises(RuntimeError , " Abnormal exit has no exit code" ) do
32
- status_for(:interrupted ).exit_code
33
- end
34
- else
35
- status_for(:interrupted ).exit_code.should eq({% if flag?(:unix ) % }0 {% else % }LibC ::STATUS_CONTROL_C_EXIT .to_i32!{% end % })
30
+ expect_raises(RuntimeError , " Abnormal exit has no exit code" ) do
31
+ status_for(:interrupted ).exit_code
36
32
end
37
33
end
38
34
@@ -43,7 +39,7 @@ describe Process::Status do
43
39
Process ::Status .new(exit_status(128 )).exit_code?.should eq 128
44
40
Process ::Status .new(exit_status(255 )).exit_code?.should eq 255
45
41
46
- status_for(:interrupted ).exit_code?.should eq({ % if flag?( :unix ) % } nil { % else % } LibC :: STATUS_CONTROL_C_EXIT .to_i32!{ % end % })
42
+ status_for(:interrupted ).exit_code?.should be_nil
47
43
end
48
44
49
45
it " #success?" do
@@ -63,7 +59,7 @@ describe Process::Status do
63
59
Process ::Status .new(exit_status(128 )).normal_exit?.should be_true
64
60
Process ::Status .new(exit_status(255 )).normal_exit?.should be_true
65
61
66
- status_for(:interrupted ).normal_exit?.should eq {{ flag?( :win32 ) }}
62
+ status_for(:interrupted ).normal_exit?.should be_false
67
63
end
68
64
69
65
it " #signal_exit?" do
Original file line number Diff line number Diff line change @@ -135,7 +135,8 @@ class Process::Status
135
135
@exit_status & 0xC0000000 _u32 == 0 ? ExitReason ::Normal : ExitReason ::Unknown
136
136
end
137
137
{% elsif flag?(:unix ) && ! flag?(:wasm32 ) % }
138
- if normal_exit?
138
+ # define __WIFEXITED(status) (__WTERMSIG(status) == 0)
139
+ if signal_code == 0
139
140
ExitReason ::Normal
140
141
elsif signal_exit?
141
142
case Signal .from_value?(signal_code)
@@ -181,13 +182,12 @@ class Process::Status
181
182
end
182
183
183
184
# Returns `true` if the process terminated normally.
185
+ #
186
+ # Equivalent to `ExitReason::Normal`
187
+ #
188
+ # * `#exit_reason` provides more insights into other exit reasons.
184
189
def normal_exit ? : Bool
185
- {% if flag?(:unix ) % }
186
- # define __WIFEXITED(status) (__WTERMSIG(status) == 0)
187
- signal_code == 0
188
- {% else % }
189
- true
190
- {% end % }
190
+ exit_reason.normal?
191
191
end
192
192
193
193
# If `signal_exit?` is `true`, returns the *Signal* the process
@@ -228,9 +228,9 @@ class Process::Status
228
228
# Process.new("sleep", ["10"]).tap(&.terminate).wait.exit_code? # => nil
229
229
# ```
230
230
def exit_code ? : Int32 ?
231
- {% if flag?(:unix ) % }
232
- return unless normal_exit?
231
+ return unless normal_exit?
233
232
233
+ {% if flag?(:unix ) % }
234
234
# define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
235
235
(@exit_status & 0xff00 ) >> 8
236
236
{% else % }
You can’t perform that action at this time.
0 commit comments