瀏覽代碼

preserve rebar path when running `ct` and `eunit` tests

pull/88/head
alisdair sullivan 10 年之前
父節點
當前提交
e5270da3d7
共有 2 個檔案被更改,包括 8 行新增3 行删除
  1. +3
    -1
      src/rebar_prv_common_test.erl
  2. +5
    -2
      src/rebar_prv_eunit.erl

+ 3
- 1
src/rebar_prv_common_test.erl 查看文件

@ -41,7 +41,7 @@ do(State) ->
OutDir = case proplists:get_value(outdir, RawOpts, undefined) of OutDir = case proplists:get_value(outdir, RawOpts, undefined) of
undefined -> filename:join([rebar_state:dir(State), undefined -> filename:join([rebar_state:dir(State),
ec_file:insecure_mkdtemp()]); ec_file:insecure_mkdtemp()]);
Path -> Path
Out -> Out
end, end,
InDir = proplists:get_value(dir, Opts, []), InDir = proplists:get_value(dir, Opts, []),
ok = create_dirs(Opts), ok = create_dirs(Opts),
@ -56,9 +56,11 @@ do(State) ->
TestState = first_files(test_opts(S, InDir, OutDir)), TestState = first_files(test_opts(S, InDir, OutDir)),
ok = rebar_erlc_compiler:compile(TestState, AppDir) ok = rebar_erlc_compiler:compile(TestState, AppDir)
end, ProjectApps), end, ProjectApps),
Path = code:get_path(),
true = code:add_patha(OutDir), true = code:add_patha(OutDir),
CTOpts = resolve_ct_opts(State, Opts), CTOpts = resolve_ct_opts(State, Opts),
Result = handle_results(ct:run_test([{dir, OutDir}] ++ CTOpts)), Result = handle_results(ct:run_test([{dir, OutDir}] ++ CTOpts)),
true = code:set_path(Path),
case Result of case Result of
{error, Reason} -> {error, Reason} ->
{error, {?MODULE, Reason}}; {error, {?MODULE, Reason}};

+ 5
- 2
src/rebar_prv_eunit.erl 查看文件

@ -41,7 +41,7 @@ do(State) ->
OutDir = case proplists:get_value(outdir, Opts, undefined) of OutDir = case proplists:get_value(outdir, Opts, undefined) of
undefined -> filename:join([rebar_state:dir(State), undefined -> filename:join([rebar_state:dir(State),
ec_file:insecure_mkdtemp()]); ec_file:insecure_mkdtemp()]);
Path -> Path
Out -> Out
end, end,
?DEBUG("Compiling EUnit instrumented modules in: ~p", [OutDir]), ?DEBUG("Compiling EUnit instrumented modules in: ~p", [OutDir]),
lists:foreach(fun(App) -> lists:foreach(fun(App) ->
@ -54,11 +54,14 @@ do(State) ->
TestState = first_files(test_opts(S, OutDir)), TestState = first_files(test_opts(S, OutDir)),
ok = rebar_erlc_compiler:compile(TestState, AppDir) ok = rebar_erlc_compiler:compile(TestState, AppDir)
end, ProjectApps), end, ProjectApps),
Path = code:get_path(),
true = code:add_patha(OutDir), true = code:add_patha(OutDir),
EUnitOpts = resolve_eunit_opts(State, Opts), EUnitOpts = resolve_eunit_opts(State, Opts),
AppsToTest = [{application, erlang:binary_to_atom(rebar_app_info:name(App), unicode)} AppsToTest = [{application, erlang:binary_to_atom(rebar_app_info:name(App), unicode)}
|| App <- ProjectApps], || App <- ProjectApps],
case handle_results(eunit:test(AppsToTest, EUnitOpts)) of
Result = eunit:test(AppsToTest, EUnitOpts),
true = code:set_path(Path),
case handle_results(Result) of
{error, Reason} -> {error, Reason} ->
{error, {?MODULE, Reason}}; {error, {?MODULE, Reason}};
ok -> ok ->

Loading…
取消
儲存