Common Test hooks for more readable logs
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
test
.gitignore
LICENSE
README.md
rebar.config
rebar.config.script
rebar.lock

README.md

cth_readable

An OTP library to be used for CT log outputs you want to be readable around all that noise they contain.

There are currently the following hooks:

  1. cth_readable_shell, which shows failure stacktraces in the shell and otherwise shows successes properly, in color.
  2. cth_readable_compact_shell, which is similar to the previous ones, but only ouputs a period (.) for each successful test
  3. cth_readable_failonly, which only outputs error and SASL logs to the shell in case of failures. It also provides cthr:pal/1-4 functions, working like ct:pal/1-4, but being silenceable by that hook. A parse transform exists to automatically convert ct:pal/1-3 into cthr:pal/1-3. Also automatically handles lager.
  4. cth_readable_nosasl, which disables all SASL logging. It however requires to be run before cth_readable_failonly to work.

What it looks like

example example

Usage with rebar3

Supported and enabled by default.

Usage with rebar2.x

Add the following to your rebar.config:

{deps, [
    {cth_readable, {git, "https://github.com/ferd/cth_readable.git", {tag, "v1.1.0"}}}
    ]}.

{ct_opts, [{ct_hooks, [cth_readable_failonly, cth_readable_shell]}]}.
{ct_compile_opts, [{parse_transform, cth_readable_transform}]}.

Usage with lager

If your lager handler has a custom formatter and you want that formatter to take effect, rather than using a configuration such as:

{lager, [
  {handlers, [{lager_console_backend,
                [info, {custom_formatter, [{app, "some-val"}]}]}
             ]}
]}.

Use:

{lager, [
  {handlers, [{cth_readable_lager_backend,
                [info, {custom_formatter, [{app, "some-val"}]}]}
             ]}
]}.

It will let you have both proper formatting and support for arbitrary configurations.

Changelog

1.4.2:

  • OTP-21.0 support (Logger interface)

1.4.1:

  • OTP-21-rc2 support (Logger interface); dropping rc1 support.

1.4.0:

  • OTP-21-rc1 support (Logger interface)
  • Add compact shell output handler

1.3.4:

  • Restore proper eunit assertion formatting

1.3.3:

  • More fixes due to lager old default config formats

1.3.2:

  • Fix deprecation warning on newer lagers due to old default config format

1.3.1:

  • Unicode support and OTP-21 readiness.

1.3.0:

  • display groups in test output. Thanks to @egobrain for the contribution

1.2.6:

  • report end_per_testcase errors as a non-critical failure when the test case passes
  • add in a (voluntarily failing) test suite to demo multiple output cases required

1.2.5:

  • support for on_tc_skip/4 to fully prevent misreporting of skipped suites

1.2.4:

  • unset suite name at the end of hooks run to prevent misreporting

1.2.3:

  • correct syntax_lib to syntax_tools as an app dependency

1.2.2:

  • fix output for assertions

1.2.1:

  • handle failures of parse transforms by just ignoring the culprit files.

1.2.0:

  • move to cf library for color output, adding support for 'dumb' terminals

1.1.1:

  • fix typo of poplist -> proplist, thanks to @egobrain

1.1.0:

  • support for better looking EUnit logs
  • support for lager backends logging to HTML files

1.0.1:

  • support for CT versions in Erlang copies older than R16

1.0.0:

  • initial stable release