[cmake-developers] ctest doesn't respect --output-on-failure if --quiet is also specified

Steve Lorimer steve.lorimer at gmail.com
Tue Aug 23 13:11:59 EDT 2016


Maybe I just don't know how to use ctest properly.

I'm trying to suppress ctest's output *except* if there is a test failure.

As such, I'm running with the following command:

    ctest --output-on-failure --quiet

According to the man page, --quiet suppresses --verbose, --extra-verbose
and --debug.

According to the man page, --output-on-failure displays anything outputted
by the test program if the test should fail.

Is there a way to get the best of both worlds? That is, suppress everything
unless there is a failure, only display the failing test's output and
ctest's output for the failing test.

Here are my various tests cases:

*1. ctest with no arguments:*

$ ctest
Test project /home/steve/src/cmake_test/.build/debug
    Start 1: foo_test
1/2 Test #1: foo_test .........................   Passed    1.86 sec
    Start 2: bar_test
2/2 Test #2: bar_test .........................***Failed    1.92 sec

50% tests passed, 1 tests failed out of 2

Total Test time (real) =   3.78 sec

The following tests FAILED:
 2 - bar_test (Failed)
Errors while running CTest



*2. ctest with quiet only*

$ ctest --quiet


*3. ctest with output-on-failure only*

$ ctest --output-on-failure
Test project /home/steve/src/cmake_test/.build/debug
    Start 1: foo_test
1/2 Test #1: foo_test .........................   Passed    1.81 sec
    Start 2: bar_test
2/2 Test #2: bar_test .........................***Failed    1.91 sec
Running 1 test case...
testing bar
/home/steve/src/cmake_test/bar/test/main.cpp(10): fatal error: in
"bar_test": critical check bar() == "123 bar" has failed [123 bar foo !=
123 bar]

*** 1 failure is detected in the test module "Master Test Suite"


50% tests passed, 1 tests failed out of 2

Total Test time (real) =   3.71 sec

The following tests FAILED:
 2 - bar_test (Failed)
Errors while running CTest


*4. ctest with both quiet and output-on-failure*

$ ctest --output-on-failure --quiet


Why no error output?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20160823/2a0f9f45/attachment.html>


More information about the cmake-developers mailing list