]> granicus.if.org Git - ejabberd/commitdiff
Better error reporting when running Elixir test suite
authorMickael Remond <mremond@process-one.net>
Tue, 15 Mar 2016 21:42:07 +0000 (22:42 +0100)
committerMickael Remond <mremond@process-one.net>
Tue, 15 Mar 2016 21:42:07 +0000 (22:42 +0100)
test/elixir_SUITE.erl

index 6243456bdeb54b63913e74440860728e963d0c6e..b9a0b1a231101f4b42bfe48908a946d36b2e7840 100644 (file)
@@ -8,7 +8,7 @@
 %%% Example: Is run with:
 %%%     ./rebar skip_deps=true ct suites=elixir
 %%% or from ejabber overall test suite:
-%%%     make test
+%%%     make quicktest
 %%% @end
 %%% Created :  19 Feb 2015 by Mickael Remond <mremond@process-one.net>
 %%%-------------------------------------------------------------------
 
 -compile(export_all).
 
+init_per_suite(Config) ->
+    check_meck(),
+    Config.
+
 init_per_testcase(_TestCase, Config) ->
     process_flag(error_handler, ?MODULE),
     Config.
@@ -32,9 +36,19 @@ all() ->
             []
     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() ->
     case catch elixir:module_info() of
         {'EXIT',{undef,_}} ->
+            ct:print("ejabberd has not been build with Elixir support, skipping Elixir tests."),
             false;
         ModInfo when is_list(ModInfo) ->
             true
@@ -55,7 +69,14 @@ run_elixir_test(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
     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() ->
     {ok, CWD} = file:get_cwd(),