ferd / cth_readable Goto Github PK
View Code? Open in Web Editor NEWCommon Test hooks for more readable logs
License: Other
Common Test hooks for more readable logs
License: Other
this comes from my console:
===> Verifying dependencies...
escript: exception error: no match of right hand side value
{error,
{rebar_app_utils,
{missing_package,<<"cth_readable">>,<<"1.4.6">>}}}
in function erl_eval:expr/5 (erl_eval.erl, line 453)
in call from escript:eval_exprs/5 (escript.erl, line 872)
in call from erl_eval:local_func/6 (erl_eval.erl, line 567)
in call from escript:interpret/4 (escript.erl, line 788)
in call from escript:start/1 (escript.erl, line 277)
in call from init:start_em/1 (init.erl, line 1115)
in call from init:do_boot/3 (init.erl, line 823)
When fetching the package from hex.pm, the tests are missing. Thus one can not check whether the package is actually working (passing tests) in the own environment.
Please add the tests to the hex.pm package (and publch a new version ;-). Thanks.
We ran into an issue with cth_readable
where the gen_server in cth_readable_failonly
consumes large quantities of memory, due to it buffering all IO in the gen_server state.
Would a PR be considered, where we make this configurable, and only buffer the last X events for printout, with the default being the current behavior?
I use v1.4.9. In cth_readable_failonly:call_handlers/2 has_logger is cth_readable_logger.
In the next line that handler is called with
gen_event:call(Name, Handler, Msg, 300000)
I've the following error if I put this into a try/catch:
cth_readable_failonly 350 {Error, Stack}: '{{noproc,
{gen_event,call,
[cth_readable_logger,
cth_readable_failonly,flush,
300000]}},
[{gen_event,call1,4,
[{file,"gen_event.erl"},
{line,302}]},
{cth_readable_failonly,
'-call_handlers/2-lc$^0/1-0-',3,
[{file,
"rds/_build/test/lib/cth_readable/src/cth_readable_failonly.erl"},
{line,348}]},
{cth_readable_failonly,
call_handlers,2,
[{file,
"rds/_build/test/lib/cth_readable/src/cth_readable_failonly.erl"},
{line,354}]},
Because of this my tests are failing. When I was debugging it I saw cth_readable_logger was added
using gen_event:handler in adding_handler function before this error.
Do you have an idea what could happen with that process? Have you seen something like this?
When I try to build this as a standalone rebar project (using d9cefd0), I get the following error:
$ DEBUG=1 ./rebar3 compile
===> Evaluating config script "rebar.config.script"
===> Load global config file /root/.config/rebar3/rebar.config
===> Expanded command sequence to be run: [{default,app_discovery},
{default,install_deps},
{default,lock},
{default,compile}]
===> Provider: {default,app_discovery}
===> Provider: {default,install_deps}
===> Verifying dependencies...
===> Provider: {default,lock}
===> Provider: {default,compile}
===> run_hooks("/mnt/hgfs/Workspace/cth_readable", pre_hooks, compile) -> no hooks defined
===> Compiling cth_readable
===> run_hooks("/mnt/hgfs/Workspace/cth_readable", pre_hooks, compile) -> no hooks defined
===> run_hooks("/mnt/hgfs/Workspace/cth_readable", pre_hooks, erlc_compile) -> no hooks defined
===> erlopts [debug_info]
===> files to compile ["/mnt/hgfs/Workspace/cth_readable/src/cth_readable_transform.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_compact_shell.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_helpers.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cthr.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_nosasl.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_shell.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_lager_backend.erl",
"/mnt/hgfs/Workspace/cth_readable/src/cth_readable_failonly.erl"]
===> Compiling src/cthr.erl failed
src/cthr.erl:3: can't find include lib "common_test/include/ct.hrl"; Make sure common_test is in your app file's 'applications' list
src/cthr.erl:83: Warning: function format/4 is unused
===> Compilation failed: {error,
[["src/cthr.erl:3: can't find include lib \"common_test/include/ct.hrl\"; Make sure common_test is in your app file's 'applications' list\n"]],
[["src/cthr.erl:83: Warning: function format/4 is unused\n"]]}
This is using rebar 3.9.0 on Erlang/OTP 21 Erts 10.2.3 (Centos 7.6.1810).
Is there something I'm doing wrong?
This is mostly for information - at least for now. The main problem is in common_test
, but when that is corrected it might require an update of cth_readable_shell
.
Since the hook function on_tc_skip/3
does not include the name of the suite, cth_readable_shell
is depending on pre_init_per_suite/3
to get the suite name and store it in the hook state. The problem is that when a suite is skipped by specifying a skip_suites
statement in the test spec, there is no call to pre_init_per_suite/3
or any other hook function except on_tc_skip/3
(with TC=all
). The consequence of this is that cth_readable_shell
will print skip info for either the previous suite (if there is one), or for the suite undefined
(if the skipped suite is the first to be handled):
%%% undefined ==> all: SKIPPED
%%% undefined ==> {tc_user_skip,"...skip reason..."}
There is currently no workaround for this problem, but it might be a good idea to 'unset' the suite name in the state on post_end_per_suite/4
in order to avoid the faulty skip info if a previous suite existed, for example:
%%% reltool_app_SUITE ==> fields: OK
%%% reltool_app_SUITE ==> modules: OK
%%% reltool_app_SUITE ==> export_all: OK
%%% reltool_app_SUITE ==> app_depend: OK
%%% reltool_app_SUITE ==> undef_funcs: OK
%%% reltool_app_SUITE ==> appup: OK
%%% reltool_app_SUITE ==> all: SKIPPED <-----------
%%% reltool_app_SUITE ==> {tc_user_skip,"...skip reason..."} <-----------
During testing it was discovered that calls to ct:pal/5
were failing with undef errors when the parse_transform cth_readable_transform
was used. This is because cthr:pal/5
does not exist.
Implement cthr:pal/5
(which has support for opts).
Please see commit ashleyjlive@46c0a80
Given the following suite foo_SUITE
:
-module(foo_SUITE).
-export([
suite/0,
all/0,
groups/0,
init_per_suite/1,
end_per_suite/1,
init_per_group/2,
end_per_group/2,
init_per_testcase/2,
end_per_testcase/2
]).
-export([a/1, b/1, c/1]).
suite() ->
[{timetrap, {seconds, 10}}].
init_per_suite(Config) ->
Config.
end_per_suite(_Config) ->
ok.
init_per_group(_GroupName, Config) ->
Config.
end_per_group(_GroupName, _Config) ->
ok.
init_per_testcase(_TestCase, Config) ->
Config.
end_per_testcase(_TestCase, _Config) ->
ok.
groups() ->
[
{as, [parallel], [
a,
{group, bs}
]},
{bs, [parallel], [
b
]},
{all, [parallel], [
{group, as},
c
]}
].
all() ->
[
{group, all}
].
a(_) -> timer:sleep(1000), error(a).
b(_) -> timer:sleep(1000), error(b).
c(_) -> timer:sleep(1000), error(c).
Running the default rebar3 ct
produces:
%%% foo_SUITE:
%%% foo_SUITE ==> all.as.bs.a: FAILED
%%% foo_SUITE ==> {a,[{foo_SUITE,a,1,
[{file,"/data/users/micmus/github/erlfmt/test/foo_SUITE.erl"},
{line,58}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1748}]},
{test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1263}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1195}]}]}
%%% foo_SUITE ==> all.as.bs.b: FAILED
%%% foo_SUITE ==> {b,[{foo_SUITE,b,1,
[{file,"/data/users/micmus/github/erlfmt/test/foo_SUITE.erl"},
{line,60}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1748}]},
{test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1263}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1195}]}]}
%%% foo_SUITE ==> all.c: FAILED
%%% foo_SUITE ==> {c,[{foo_SUITE,c,1,
[{file,"/data/users/micmus/github/erlfmt/test/foo_SUITE.erl"},
{line,62}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1748}]},
{test_server,run_test_case_eval1,6,[{file,"test_server.erl"},{line,1263}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1195}]}]}
Note the incorrecy name all.as.bs.a
- test a
does not belong to bs
group.
https://hex.pm/packages/cth_readable/1.4.8 shows Dependencies (0)
https://hex.pm/packages/cth_readable/1.4.7 Dependencies (1) cf ~>0.2.1
The readable helper for assert failure assuming the failure is either false
or not a boolean: https://github.com/ferd/cth_readable/blob/master/src/cth_readable_helpers.erl#L33 but with assertNot
the failure would be true
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.