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

exec: improve information on command execution error #499

Merged
merged 7 commits into from
Jan 11, 2024
Merged

exec: improve information on command execution error #499

merged 7 commits into from
Jan 11, 2024

Conversation

fho
Copy link
Collaborator

@fho fho commented Jan 11, 2024

exec: include stream name and WARN: in outputstream log messages

If an error happens when streaming the output, always include the stream name
and WARN in the related log message.

Some internal variable names are also shortened.

-------------------------------------------------------------------------------
tests: add simple exec stdout streaming testcase

-------------------------------------------------------------------------------
exec: fix: duplicate newlines in streaming output

When "--verbose" was passed to "baur run" the logger was used as logf function.
The logger appends a "\n" when the last character is not already a newline.
Because "\n" character was colorized with the logFnStderrStreamColorfn, the
logger did not detect the newline anymore and appended a second one.

Do not pass "\n" to c.logFnStderrStreamColorfn.

-------------------------------------------------------------------------------
run: improve command error output format

Move colorizing the output of command errors to the command package.
This allows more fine granular coloring

-------------------------------------------------------------------------------
exec: include command and execution directory in error message

When a command exited unsuccessfully, include the executed command and the
directory in which it was run in the error message.

-------------------------------------------------------------------------------
test: use testify in exec tests

-------------------------------------------------------------------------------
exec: improve error handling

- extend the error message to contain the information that the process was
  killed by signal or because of a broken pipe by using the message from
  exec.ExitError
- instead of checking if a process exited with code 0, check for success by
  calling ProcessState.Success(), this is platform independent and also works as
  expected if a platform uses another code then 0 to indicate success

-------------------------------------------------------------------------------
tests: add exec testcase for recorded and streamed output

Add testcases that verfify that the streamed output and the prefixSaver outputs
are complete when the the process mixes stdout and stderr output.

-------------------------------------------------------------------------------

@fho fho self-assigned this Jan 11, 2024
fho added 2 commits January 11, 2024 18:58
- extend the error message to contain the information that the process was
  killed by signal or because of a broken pipe by using the message from
  exec.ExitError
- instead of checking if a process exited with code 0, check for success by
  calling ProcessState.Success(), this is platform independent and also works as
  expected if a platform uses another code then 0 to indicate success
fho added 5 commits January 11, 2024 19:08
When a command exited unsuccessfully, include the executed command and the
directory in which it was run in the error message.
Move colorizing the output of command errors to the command package.
This allows more fine granular coloring
When "--verbose" was passed to "baur run" the logger was used as logf function.
The logger appends a "\n" when the last character is not already a newline.
Because "\n" character was colorized with the logFnStderrStreamColorfn, the
logger did not detect the newline anymore and appended a second one.

Do not pass "\n" to c.logFnStderrStreamColorfn.
If an error happens when streaming the output, always include the stream name
and WARN in the related log message.

Some internal variable names are also shortened.
@fho fho marked this pull request as ready for review January 11, 2024 18:22
@fho fho merged commit 00c5c61 into main Jan 11, 2024
4 checks passed
@fho fho deleted the exec1 branch January 11, 2024 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant