the Compartmented Robust Posix C++ Unit Test system

Chapter 4. Environment variables

CRPCUT_TEXT_DECORATION

This environment variable controls experimental support for decorations in human readable test reports (i.e. non XML reports.) It is typically used for colourizing the output, but is not specialized for it.

The syntax (subject to change) is:


      CRPCUT_TEXT_DECORATION = SEPARATOR VALUE DECORATORLIST SEPARATOR
      SEPARATOR = char
      VALUE = [^SEPARATOR]+
      DECORATORLIST =
                    |  DECORATORDEF SEPARATOR DECORATORLIST
      DECORATORDEF  =  DECORATORNAME '=' VALUE
      DECORATORNAME = 'PASSED'
                    | 'FAILED'
                    | 'NCPASSED'      /* defaults to same as PASSED   */
                    | 'NCFAILED'      /* defaults to same as FAILED   */
                    | 'BLOCKED'
                    | 'PASSED_SUM'    /* defaults to same as PASSED   */
                    | 'FAILED_SUM'    /* defaults to same as FAILED   */
                    | 'NCPASSED_SUM'  /* defaults to same as NCPASSED */
                    | 'NCFAILED_SUM'  /* defaults to same as NCFAILED */
                    | 'BLOCKED_SUM'   /* defaults to same as BLOCKED  */
    

SEPARATOR can be any character that is not used in any value, and is repeated between each decorator definition.

The first value is the reset value, a string printed at the end of every section. The other value are:

FAILED
Printed at the beginning of the result from a failed test. This is also used for tags in the tag-list which have failed tests.
NCFAILED
Printed at the beginning of the result from a non-critical test that has failed. This is also used for non-critical tags in the tag-list which have failed tests. Defaults to the same as FAILED if not specified.
PASSED
Printed at the beginning of the result from a passed test. This is also used for tags in the tag-list for which all tests have passed.
NCPASSED
Printed at the beginning of the result from a non-critical test that has passed. This is also used for non-critical tags in the tag-list for which all tests have passed. Defaults to the same as PASSED ifnot specified.
BLOCKED
Printed at the beginning of each test name the list of blocked tests.
FAILED_SUM
Printed at the beginning of the FAILED line of the report summary, if there are failed tests. Defaults to the same as FAILED if not specified.
NCFAILED_SUM
Printed at the beginning of the FAILED line of the report summary if all failed tests are non-critical. Defaults to the same as NCFAILED if not specified.
PASSED_SUM
Printed at the beginning of the PASSED line of the report summary if there are tests that have passed. Defaults to the same as PASSED if not specified.
NCPASSED_SUM
Printed at the beginning of the PASSED line of the reprort summary if all tests that passed are non-critical. Defaults to the same as NCPASSED if not specified.
BLOCKED_SUM
Printed at the beginning of the BLOCKED line in the report summary, if there any blocked tests. Defaults to the same as BLOCKED if not specified.

An example using ANSI-escapes in bash-syntax:


      $> export CRPCUT_TEXT_DECORATION=$'
      \E[0m
      BLOCKED=\E[35m
      PASSED=\E[32m
      FAILED=\E[31m
      NCFAILED=\E[33m
      PASSED_SUM=\E[42m\E[37m\E[1m
      FAILED_SUM=\E[41m\E[37m\E[1m
      BLOCKED_SUM=\E[45m\E[37m\E[1m
      '
    

This uses the reset sequence \x1b[0m as the reset value. Blocked tests are printed purple. Passed tests (both critical and non-critical) are coloured green using the escape sequence \x1b[32m. Failed critical tests are coloured red using the escape sequence \x1b[31m, and non-critital tests are printed in yellow with the \x1b[33m. In the summary, all lines use the corresponding colours, but printed inverse with bold white text.

An example test report has, with possible differences in colour representation, the following appearence:

    PASSED!: basics::construct
    info---------------------------------------------------------------------------
    /home/bjorn/devel/crpcut/doc-src/samples/report_example.cpp:51
    created an A, addr=0x639860
    ===============================================================================
    FAILED!: basics::call_func
    phase="running"  --------------------------------------------------------------
    /home/bjorn/devel/crpcut/doc-src/samples/report_example.cpp:56
    ASSERT_TRUE(func() == 1)
      is evaluated as:
        3 == 1
    -------------------------------------------------------------------------------
    ===============================================================================
    FAILED?: basics::destroy
    info---------------------------------------------------------------------------
    /home/bjorn/devel/crpcut/doc-src/samples/report_example.cpp:61
    running test body
    -------------------------------------------------------------------------------
    /tmp/crpcutSOimFW/basics::destroy is not empty!
    phase="destroying"  -----------------------------------------------------------
    /home/bjorn/devel/crpcut/doc-src/samples/report_example.cpp:59
    Died with core dump
    -------------------------------------------------------------------------------
    ===============================================================================
    Files remain under /tmp/crpcutSOimFW
    The following tests were blocked from running:
      -basics::will_not_run
      !toy::work
    5 test cases selected
     tag             run  passed  failed
    !a_tag             2       1       1
    ?another_tag       1       0       1
    
                   Sum   Critical   Non-critical
    PASSED   :       1          1              0
    FAILED   :       2          1              1
    UNTESTED :       2