25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-12-26 17:38:45 +01:00

Better error reporting when running Elixir test suite

This commit is contained in:
Mickael Remond 2016-03-15 22:42:07 +01:00
parent 9ceeaf213b
commit 367adc2113

View File

@ -8,7 +8,7 @@
%%% Example: Is run with: %%% Example: Is run with:
%%% ./rebar skip_deps=true ct suites=elixir %%% ./rebar skip_deps=true ct suites=elixir
%%% or from ejabber overall test suite: %%% or from ejabber overall test suite:
%%% make test %%% make quicktest
%%% @end %%% @end
%%% Created : 19 Feb 2015 by Mickael Remond <mremond@process-one.net> %%% Created : 19 Feb 2015 by Mickael Remond <mremond@process-one.net>
%%%------------------------------------------------------------------- %%%-------------------------------------------------------------------
@ -17,6 +17,10 @@
-compile(export_all). -compile(export_all).
init_per_suite(Config) ->
check_meck(),
Config.
init_per_testcase(_TestCase, Config) -> init_per_testcase(_TestCase, Config) ->
process_flag(error_handler, ?MODULE), process_flag(error_handler, ?MODULE),
Config. Config.
@ -32,9 +36,19 @@ all() ->
[] []
end. end.
check_meck() ->
case catch meck:module_info(module) of
meck ->
ok;
{'EXIT',{undef, _}} ->
ct:print("meck is not available. Please make sure you configured ejabberd with --enable-elixir --enable-tools"),
ok
end.
is_elixir_available() -> is_elixir_available() ->
case catch elixir:module_info() of case catch elixir:module_info() of
{'EXIT',{undef,_}} -> {'EXIT',{undef,_}} ->
ct:print("ejabberd has not been build with Elixir support, skipping Elixir tests."),
false; false;
ModInfo when is_list(ModInfo) -> ModInfo when is_list(ModInfo) ->
true true
@ -55,7 +69,14 @@ run_elixir_test(Func) ->
'Elixir.Code':load_file(list_to_binary(filename:join(test_dir(), atom_to_list(Func)))), 'Elixir.Code':load_file(list_to_binary(filename:join(test_dir(), atom_to_list(Func)))),
%% I did not use map syntax, so that this file can still be build under R16 %% I did not use map syntax, so that this file can still be build under R16
ResultMap = 'Elixir.ExUnit':run(), ResultMap = 'Elixir.ExUnit':run(),
{ok, 0} = maps:find(failures, ResultMap). case maps:find(failures, ResultMap) of
{ok, 0} ->
%% Zero failures
ok;
{ok, Failures} ->
ct:print("Elixir tests failed: ~.10B~nSee logs for details", [Failures]),
ct:fail(elixir_test_failure)
end.
test_dir() -> test_dir() ->
{ok, CWD} = file:get_cwd(), {ok, CWD} = file:get_cwd(),