Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMickaël Rémond <mickael.remond@process-one.net>2015-03-04 00:15:24 +0300
committerMickaël Rémond <mickael.remond@process-one.net>2015-03-04 00:15:24 +0300
commit02dd3ae0afb3fb4dc96886640e8958538430247a (patch)
tree2c2062e9a31387a32f190ba32dbac593576196bd /test
parentcffe0b0dfe76c3223b66a6e0167a204b49497287 (diff)
parent17be6a303ba4bfbf773d0f0c7aa9e4d6ecc0d837 (diff)
Merge pull request #441 from mremond/test/#438/run-elixir-tests
Support for running Elixir ExUnit tests from Common Test
Diffstat (limited to 'test')
-rw-r--r--test/elixir_SUITE.erl57
1 files changed, 57 insertions, 0 deletions
diff --git a/test/elixir_SUITE.erl b/test/elixir_SUITE.erl
new file mode 100644
index 000000000..ec5dc5ec6
--- /dev/null
+++ b/test/elixir_SUITE.erl
@@ -0,0 +1,57 @@
+%%%-------------------------------------------------------------------
+%%% @author Mickael Remond <mremond@process-one.net>
+%%% @copyright (C) 2002-2015, ProcessOne
+%%% @doc
+%%% This is a common test wrapper to run our ejabberd tests written in
+%%% Elixir from standard common test code.
+%%%
+%%% Example: Is run with:
+%%% ./rebar skip_deps=true ct suites=elixir
+%%% or from ejabber overall test suite:
+%%% make test
+%%% @end
+%%% Created : 19 Feb 2015 by Mickael Remond <mremond@process-one.net>
+%%%-------------------------------------------------------------------
+
+-module(elixir_SUITE).
+
+-compile(export_all).
+
+init_per_testcase(_TestCase, Config) ->
+ process_flag(error_handler, ?MODULE),
+ Config.
+
+all() ->
+ case is_elixir_available() of
+ true ->
+ Dir = test_dir(),
+ filelib:fold_files(Dir, ".*\.exs", false,
+ fun(Filename, Acc) -> [list_to_atom(filename:basename(Filename)) | Acc] end,
+ []);
+ false ->
+ []
+ end.
+
+is_elixir_available() ->
+ case catch elixir:module_info() of
+ {'EXIT',{undef,_}} ->
+ false;
+ ModInfo when is_list(ModInfo) ->
+ true
+ end.
+
+undefined_function(?MODULE, Func, Args) ->
+ case lists:suffix(".exs", atom_to_list(Func)) of
+ true ->
+ 'Elixir.ExUnit':start([]),
+ 'Elixir.Code':load_file(list_to_binary(filename:join(test_dir(), atom_to_list(Func)))),
+ 'Elixir.ExUnit':run();
+ false ->
+ error_handler:undefined_function(?MODULE, Func, Args)
+ end;
+undefined_function(Module, Func, Args) ->
+ error_handler:undefined_function(Module, Func,Args).
+
+test_dir() ->
+ {ok, CWD} = file:get_cwd(),
+ filename:join(CWD, "../../test").