the Compartmented Robust Posix C++ Unit Test system

Chapter 4. Environment variables

CRPCUT_TEXT_DECORATION

This environment variable controls 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.

Syntax:


      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.

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 both in the list and the summary. 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, the line with failed tests are printed with white bold on red background using the espace sequence \x1b[41m\x1b[37m\x1b[1m if there are any failed critical tests, otherwise yellow is used (as defined for failed non-critical tests.)

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

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