Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor use of Process::Status#exit_code to #exit_code? #15254

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/compiler/crystal/command.cr
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ class Crystal::Command
puts "Execute: #{elapsed_time}"
end

if status.exit_reason.normal? && !error_on_exit
exit status.exit_code
if (exit_code = status.exit_code?) && !error_on_exit
exit exit_code
end

if message = exit_message(status)
Expand Down
19 changes: 10 additions & 9 deletions src/compiler/crystal/compiler.cr
Original file line number Diff line number Diff line change
Expand Up @@ -876,16 +876,17 @@ module Crystal

status = $?
unless status.success?
if status.normal_exit?
case status.exit_code
when 126
linker_not_found File::AccessDeniedError, linker_name
when 127
linker_not_found File::NotFoundError, linker_name
end
exit_code = status.exit_code?
case exit_code
when 126
linker_not_found File::AccessDeniedError, linker_name
when 127
linker_not_found File::NotFoundError, linker_name
when nil
# abnormal exit
exit_code = 1
end
code = status.normal_exit? ? status.exit_code : 1
error "execution of command failed with exit status #{status}: #{command}", exit_code: code
error "execution of command failed with exit status #{status}: #{command}", exit_code: exit_code
end
end

Expand Down
2 changes: 1 addition & 1 deletion src/compiler/crystal/macros/methods.cr
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ module Crystal
command = "#{Process.quote(original_filename)} #{Process.quote(run_args)}"

message = IO::Memory.new
message << "Error executing run (exit code: #{result.status.exit_code}): #{command}\n"
message << "Error executing run (exit code: #{result.status}): #{command}\n"

if result.stdout.empty? && result.stderr.empty?
message << "\nGot no output."
Expand Down
2 changes: 1 addition & 1 deletion src/process/status.cr
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ class Process::Status

# Returns `true` if the process exited normally with an exit code of `0`.
def success? : Bool
normal_exit? && exit_code == 0
exit_code? == 0
end

private def signal_code
Expand Down
Loading