mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-24 17:29:28 +01:00
Better code for setting up ejabberd app location
This commit is contained in:
parent
f252b9d489
commit
1ade88402c
@ -18,17 +18,7 @@
|
||||
-compile(export_all).
|
||||
|
||||
init_per_suite(Config) ->
|
||||
case code:lib_dir(ejabberd) of
|
||||
{error, _} ->
|
||||
DataDir = proplists:get_value(data_dir, Config),
|
||||
{ok, CWD} = file:get_cwd(),
|
||||
NewEjPath = filename:join([CWD, "ejabberd-0.0.1"]),
|
||||
TopDir = filename:dirname(filename:dirname(filename:dirname(DataDir))),
|
||||
ok = file:make_symlink(TopDir, NewEjPath),
|
||||
code:replace_path(ejabberd, NewEjPath);
|
||||
_ ->
|
||||
ok
|
||||
end,
|
||||
suite:setup_ejabberd_lib_path(Config),
|
||||
check_meck(),
|
||||
code:add_pathz(filename:join(test_dir(), "../include")),
|
||||
Config.
|
||||
|
@ -12,6 +12,7 @@
|
||||
-compile(export_all).
|
||||
|
||||
-include("suite.hrl").
|
||||
-include_lib("kernel/include/file.hrl").
|
||||
|
||||
%%%===================================================================
|
||||
%%% API
|
||||
@ -47,10 +48,7 @@ init_config(Config) ->
|
||||
]),
|
||||
ConfigPath = filename:join([CWD, "ejabberd.yml"]),
|
||||
ok = file:write_file(ConfigPath, CfgContent),
|
||||
NewEjPath = filename:join([CWD, "ejabberd-0.0.1"]),
|
||||
TopDir = filename:dirname(filename:dirname(DataDir)),
|
||||
ok = file:make_symlink(TopDir, NewEjPath),
|
||||
code:replace_path(ejabberd, NewEjPath),
|
||||
setup_ejabberd_lib_path(Config),
|
||||
ok = application:load(sasl),
|
||||
ok = application:load(mnesia),
|
||||
ok = application:load(ejabberd),
|
||||
@ -74,6 +72,27 @@ init_config(Config) ->
|
||||
{backends, get_config_backends()}
|
||||
|Config].
|
||||
|
||||
find_top_dir(Dir) ->
|
||||
case file:read_file_info(filename:join([Dir, ebin])) of
|
||||
{ok, #file_info{type = directory}} ->
|
||||
Dir;
|
||||
_ ->
|
||||
find_top_dir(filename:dirname(Dir))
|
||||
end.
|
||||
|
||||
setup_ejabberd_lib_path(Config) ->
|
||||
case code:lib_dir(ejabberd) of
|
||||
{error, _} ->
|
||||
DataDir = proplists:get_value(data_dir, Config),
|
||||
{ok, CWD} = file:get_cwd(),
|
||||
NewEjPath = filename:join([CWD, "ejabberd-0.0.1"]),
|
||||
TopDir = find_top_dir(DataDir),
|
||||
ok = file:make_symlink(TopDir, NewEjPath),
|
||||
code:replace_path(ejabberd, NewEjPath);
|
||||
_ ->
|
||||
ok
|
||||
end.
|
||||
|
||||
%% Read environment variable CT_DB=riak,mysql to limit the backends to test.
|
||||
%% You can thus limit the backend you want to test with:
|
||||
%% CT_BACKENDS=riak,mysql rebar ct suites=ejabberd
|
||||
|
Loading…
Reference in New Issue
Block a user