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

build: Adding option to show full stdout if a stage fails #362

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion catkin_tools/execution/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ def __init__(
show_buffered_stderr=True,
show_live_stdout=False,
show_live_stderr=False,
show_stdout_on_error=False,
show_compact_io=False,
show_active_status=True,
show_summary=True,
Expand All @@ -213,6 +214,7 @@ def __init__(
:param show_buffered_stderr: Show stderr from jobs as they finish
:param show_live_stdout: Show stdout lines from jobs as they're generated
:param show_live_stderr: Show stdout lines from jobs as they're generated
:param show_stdout_on_error: Show stdout lines from job if it fails
:param show_compact_io: Don't print blank lines from redirected io
:param show_active_status: Periodically show a status line displaying the active jobs
:param show_summary: Show numbers of jobs that completed with errors and warnings
Expand All @@ -235,6 +237,7 @@ def __init__(
self.show_buffered_stderr = show_buffered_stderr
self.show_live_stdout = show_live_stdout
self.show_live_stderr = show_live_stderr
self.show_stdout_on_error = show_stdout_on_error
self.show_compact_io = show_compact_io
self.show_active_status = show_active_status
self.show_full_summary = show_full_summary
Expand Down Expand Up @@ -679,7 +682,7 @@ def run(self):
max(0, self.max_jid_length - len(event.data['job_id'])),
event.data['retcode'])

if self.show_buffered_stdout:
if self.show_buffered_stdout or (self.show_stdout_on_error and not event.data['succeeded']):
if len(event.data['interleaved']) > 0:
lines = [
l
Expand Down
4 changes: 4 additions & 0 deletions catkin_tools/verbs/catkin_build/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def build_isolated_workspace(
pre_clean=False,
force_color=False,
quiet=False,
stdout_on_error=False,
interleave_output=False,
no_status=False,
limit_status_rate=10.0,
Expand Down Expand Up @@ -203,6 +204,8 @@ def build_isolated_workspace(
:type force_color: bool
:param quiet: suppresses the output of commands unless there is an error
:type quiet: bool
:param stdout_on_error: print stdout along with stderr when there is an error
:type stdout_on_error: bool
:param interleave_output: prints the output of commands as they are received
:type interleave_output: bool
:param no_status: disables status bar
Expand Down Expand Up @@ -525,6 +528,7 @@ def build_isolated_workspace(
show_buffered_stderr=not interleave_output,
show_live_stdout=interleave_output,
show_live_stderr=interleave_output,
show_stdout_on_error=stdout_on_error,
show_stage_events=not quiet,
show_full_summary=(summarize_build is True),
pre_start_time=pre_start_time,
Expand Down
3 changes: 3 additions & 0 deletions catkin_tools/verbs/catkin_build/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ def prepare_arguments(parser):
add = behavior_group.add_argument
add('--verbose', '-v', action='store_true', default=False,
help='Print output from commands in ordered blocks once the command finishes.')
add('--verbose-errors', action='store_true', default=False,
help='Print all command output if a stage fails.')
add('--interleave-output', '-i', action='store_true', default=False,
help='Prevents ordering of command output when multiple commands are running at the same time.')
add('--no-status', action='store_true', default=False,
Expand Down Expand Up @@ -409,6 +411,7 @@ def main(opts):
pre_clean=opts.pre_clean,
force_color=opts.force_color,
quiet=not opts.verbose,
stdout_on_error=opts.verbose_errors,
interleave_output=opts.interleave_output,
no_status=opts.no_status,
limit_status_rate=opts.limit_status_rate,
Expand Down
24 changes: 24 additions & 0 deletions docs/troubleshooting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,30 @@ As a workaround, you can force CMake to ignore all specified root include direct

This is actually a bug in CMake and has been reported here: https://cmake.org/Bug/view.php?id=15970

Command-Line Output
^^^^^^^^^^^^^^^^^^^

Build Errors or Warnings Not Printing
-------------------------------------

By default, ``catkin build`` will only print error and warning messages which are written to ``stderr``.
Even if a package fails, these messages will not be shown if they are only written to ``stdout``.

If your build employs tools which print errors to ``stdout`` instead of ``stderr``, then you should use the ``--verbose-errors`` option.
This will cause all captured output from a subprocess to be printed in the event of an error:

.. code-block:: bash

catkin build --verbose-errors

If you always want to use this option, you can add it as a verb alias.
See :doc:`Verb Aliasing <advanced/verb_customization>` for more info on adding aliases.

The following programs are known to redirect error messages to ``stdout``:

- ``colorgcc`` - https://github.com/johannes/colorgcc



Migration Problems
^^^^^^^^^^^^^^^^^^
Expand Down
7 changes: 4 additions & 3 deletions docs/verbs/cli/catkin_build.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ usage: catkin build [-h] [--workspace WORKSPACE] [--profile PROFILE]
[--env-cache | --no-env-cache] [--cmake-args ARG [ARG ...]
| --no-cmake-args] [--make-args ARG [ARG ...] |
--no-make-args] [--catkin-make-args ARG [ARG ...] |
--no-catkin-make-args] [--verbose] [--interleave-output]
[--no-status] [--summarize] [--no-summarize]
[--override-build-tool-check]
--no-catkin-make-args] [--verbose] [--verbose-errors]
[--interleave-output] [--no-status] [--summarize]
[--no-summarize] [--override-build-tool-check]
[--limit-status-rate LIMIT_STATUS_RATE] [--no-notify]
[PKGNAME [PKGNAME ...]]

Expand Down Expand Up @@ -102,6 +102,7 @@ Interface:

--verbose, -v Print output from commands in ordered blocks once the
command finishes.
--verbose-errors Print all command output if a stage fails.
--interleave-output, -i
Prevents ordering of command output when multiple
commands are running at the same time.
Expand Down