fix: log debug output when commands fail#77
Open
rupayon123 wants to merge 5 commits into
Open
Conversation
Owner
|
Hi!! Sorry for the delay. Im reviewing now |
albertalef
reviewed
Jun 16, 2026
| rescue RubyShell::CommandError => e | ||
| time_two = Process.clock_gettime(Process::CLOCK_MONOTONIC) | ||
| log_command(command, time_two - time_one, e.status, e.stdout, e.stderr) | ||
| raise |
Owner
There was a problem hiding this comment.
In some situations on the past, i had some troubles with errors losing data when rescued.
This actual code will not give us problems, but. Lets add a test checking that when we have a command being rescued outside, with debug option true, the returned CommandError has the correct attributes. Like:
begin
ls('error', _debug: true)
rescue => e
puts e.command # => Correct command
puts e.stdout # => Correct stdout
# etc
end
Owner
|
Nice! Now, check the cicd, there is some failures |
albertalef
reviewed
Jun 30, 2026
| end | ||
|
|
||
| it "logs failed command stdout before reraising" do | ||
| run_failed_debug_command |
Owner
There was a problem hiding this comment.
We can separate the run_failed_debug_command on before blocks and distinct contexts, instead create a method to execute the code. To follow the idiomatic idea of rspec
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #73
Debug mode now logs the command details before re-raising
RubyShell::CommandError, so failed commands still show what ran. I also included stderr in the debug output, as requested in the issue thread.Checks:
ruby -c lib/rubyshell/debugger.rbruby -c lib/rubyshell/error.rbruby -c spec/debugger_spec.rbruby -IlibI could not run the full RSpec file locally because the
rspecexecutable is not installed here.