From 294509ad12e0a0d26020b27a4da9d699aa18029a Mon Sep 17 00:00:00 2001 From: Jonathan Bohren Date: Thu, 28 Apr 2016 14:10:08 -0400 Subject: [PATCH 1/2] build: Adding option to show full stdout if a stage fails --- catkin_tools/execution/controllers.py | 5 ++++- catkin_tools/verbs/catkin_build/build.py | 4 ++++ catkin_tools/verbs/catkin_build/cli.py | 3 +++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/catkin_tools/execution/controllers.py b/catkin_tools/execution/controllers.py index fe12c223..2bac4631 100644 --- a/catkin_tools/execution/controllers.py +++ b/catkin_tools/execution/controllers.py @@ -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, @@ -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 @@ -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 @@ -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 diff --git a/catkin_tools/verbs/catkin_build/build.py b/catkin_tools/verbs/catkin_build/build.py index 969f013a..7eeb69ee 100644 --- a/catkin_tools/verbs/catkin_build/build.py +++ b/catkin_tools/verbs/catkin_build/build.py @@ -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, @@ -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 @@ -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, diff --git a/catkin_tools/verbs/catkin_build/cli.py b/catkin_tools/verbs/catkin_build/cli.py index f6b3b7dc..4797e3bf 100644 --- a/catkin_tools/verbs/catkin_build/cli.py +++ b/catkin_tools/verbs/catkin_build/cli.py @@ -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, @@ -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, From c096eee43a4e0526d84fae4ca01da430be680337 Mon Sep 17 00:00:00 2001 From: Jonathan Bohren Date: Thu, 28 Apr 2016 16:44:09 -0400 Subject: [PATCH 2/2] doc: Adding documentation for new --verbose-errors option --- docs/troubleshooting.rst | 24 ++++++++++++++++++++++++ docs/verbs/cli/catkin_build.txt | 7 ++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/docs/troubleshooting.rst b/docs/troubleshooting.rst index 1c154a25..3df3711d 100644 --- a/docs/troubleshooting.rst +++ b/docs/troubleshooting.rst @@ -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 ` 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 ^^^^^^^^^^^^^^^^^^ diff --git a/docs/verbs/cli/catkin_build.txt b/docs/verbs/cli/catkin_build.txt index 2168ed34..ed5c63ae 100644 --- a/docs/verbs/cli/catkin_build.txt +++ b/docs/verbs/cli/catkin_build.txt @@ -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 ...]] @@ -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.