Make tests run correctly even when ejabberd src in not in ejabberd-xxx dir

This commit is contained in:
Paweł Chmielowski 2016-05-30 14:35:53 +02:00
parent e81302dc79
commit 1d3959b5a2
2 changed files with 15 additions and 4 deletions

View File

@ -18,6 +18,17 @@
-compile(export_all). -compile(export_all).
init_per_suite(Config) -> 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,
check_meck(), check_meck(),
code:add_pathz(filename:join(test_dir(), "../include")), code:add_pathz(filename:join(test_dir(), "../include")),
Config. Config.

View File

@ -47,10 +47,10 @@ init_config(Config) ->
]), ]),
ConfigPath = filename:join([CWD, "ejabberd.yml"]), ConfigPath = filename:join([CWD, "ejabberd.yml"]),
ok = file:write_file(ConfigPath, CfgContent), ok = file:write_file(ConfigPath, CfgContent),
ok = file:make_dir(filename:join([CWD, "priv"])), NewEjPath = filename:join([CWD, "ejabberd-0.0.1"]),
ok = file:make_dir(filename:join([CWD, "priv", "sql"])), TopDir = filename:dirname(filename:dirname(DataDir)),
{ok, _} = file:copy(filename:join([DataDir, "..", "..", "sql", "lite.sql"]), ok = file:make_symlink(TopDir, NewEjPath),
filename:join([CWD, "priv", "sql", "lite.sql"])), code:replace_path(ejabberd, NewEjPath),
ok = application:load(sasl), ok = application:load(sasl),
ok = application:load(mnesia), ok = application:load(mnesia),
ok = application:load(ejabberd), ok = application:load(ejabberd),