diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_git_resource.erl | 4 | ||||
-rw-r--r-- | src/rebar_prv_compile.erl | 2 | ||||
-rw-r--r-- | src/rebar_prv_eunit.erl | 62 |
3 files changed, 24 insertions, 44 deletions
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl index e2f3f69..a0690bf 100644 --- a/src/rebar_git_resource.erl +++ b/src/rebar_git_resource.erl @@ -133,9 +133,10 @@ collect_default_refcount(Dir) -> {ok, RawCount} = case Tag of undefined -> - AbortMsg2 = "Getting rev-list of git depedency failed in " ++ rebar_dir:get_cwd(), + AbortMsg2 = "Getting rev-list of git depedency failed in " ++ Dir, {ok, PatchLines} = rebar_utils:sh("git rev-list HEAD", [{use_stdout, false}, + {cd, Dir}, {debug_abort_on_error, AbortMsg2}]), rebar_utils:line_count(PatchLines); _ -> @@ -164,6 +165,7 @@ get_patch_count(Dir, RawRef) -> [Ref]), {ok, PatchLines} = rebar_utils:sh(Cmd, [{use_stdout, false}, + {cd, Dir}, {debug_abort_on_error, AbortMsg}]), rebar_utils:line_count(PatchLines). diff --git a/src/rebar_prv_compile.erl b/src/rebar_prv_compile.erl index d76fbda..74be7a6 100644 --- a/src/rebar_prv_compile.erl +++ b/src/rebar_prv_compile.erl @@ -142,7 +142,7 @@ copy_app_dirs(State, OldAppDir, AppDir) -> end, %% link to src_dirs to be adjacent to ebin is needed for R15 use of cover/xref - SrcDirs = rebar_dir:all_src_dirs(State, ["src"], ["test"]), + SrcDirs = rebar_dir:all_src_dirs(State, ["src"], []), [symlink_or_copy(OldAppDir, AppDir, Dir) || Dir <- ["priv", "include"] ++ SrcDirs]; false -> ok diff --git a/src/rebar_prv_eunit.erl b/src/rebar_prv_eunit.erl index 28c0ed6..41dd434 100644 --- a/src/rebar_prv_eunit.erl +++ b/src/rebar_prv_eunit.erl @@ -85,7 +85,8 @@ format_error({error_running_tests, Reason}) -> test_state(State) -> ErlOpts = rebar_state:get(State, eunit_compile_opts, []), TestOpts = safe_define_test_macro(ErlOpts), - first_files(State) ++ [{erl_opts, TestOpts}]. + TestDir = [{extra_src_dirs, ["test"]}], + first_files(State) ++ [{erl_opts, TestOpts ++ TestDir}]. safe_define_test_macro(Opts) -> %% defining a compile macro twice results in an exception so @@ -106,49 +107,38 @@ first_files(State) -> prepare_tests(State) -> {RawOpts, _} = rebar_state:command_parsed_args(State), - resolve_apps(State, RawOpts). + ok = maybe_cover_compile(State, RawOpts), + ProjectApps = project_apps(State), + resolve_apps(ProjectApps, RawOpts). -resolve_apps(State, RawOpts) -> +maybe_cover_compile(State, Opts) -> + State1 = case proplists:get_value(cover, Opts, false) of + true -> rebar_state:set(State, cover_enabled, true); + false -> State + end, + rebar_prv_cover:maybe_cover_compile(State1). + +resolve_apps(ProjectApps, RawOpts) -> case proplists:get_value(app, RawOpts) of - undefined -> resolve_suites(State, RawOpts); + undefined -> resolve_suites(ProjectApps, RawOpts); %% convert app name strings to `rebar_app_info` objects Apps -> AppNames = string:tokens(Apps, [$,]), - ProjectApps = project_apps(State), case filter_apps_by_name(AppNames, ProjectApps) of - {ok, TestApps} -> resolve_suites(State, TestApps, RawOpts); + {ok, TestApps} -> resolve_suites(TestApps, RawOpts); Error -> Error end end. -resolve_suites(State, RawOpts) -> resolve_suites(State, project_apps(State), RawOpts). - -resolve_suites(State, Apps, RawOpts) -> +resolve_suites(Apps, RawOpts) -> case proplists:get_value(suite, RawOpts) of - undefined -> compile_tests(State, Apps, all, RawOpts); + undefined -> test_set(Apps, all); Suites -> SuiteNames = string:tokens(Suites, [$,]), case filter_suites_by_apps(SuiteNames, Apps) of - {ok, S} -> compile_tests(State, Apps, S, RawOpts); + {ok, S} -> test_set(Apps, S); Error -> Error end end. -compile_tests(State, TestApps, Suites, RawOpts) -> - F = fun(AppInfo) -> - S = rebar_app_info:state_or_new(State, AppInfo), - ok = rebar_erlc_compiler:compile(replace_src_dirs(S), - ec_cnv:to_list(rebar_app_info:out_dir(AppInfo))) - end, - lists:foreach(F, TestApps), - ok = maybe_cover_compile(State, RawOpts), - {ok, test_set(TestApps, Suites)}. - -maybe_cover_compile(State, Opts) -> - State1 = case proplists:get_value(cover, Opts, false) of - true -> rebar_state:set(State, cover_enabled, true); - false -> State - end, - rebar_prv_cover:maybe_cover_compile(State1). - project_apps(State) -> filter_checkouts(rebar_state:project_apps(State)). @@ -215,20 +205,8 @@ app_modules([App|Rest], Acc) -> app_modules(Rest, NewAcc) end. -replace_src_dirs(State) -> - %% replace any `src_dirs` with the test dirs - ErlOpts = rebar_state:get(State, erl_opts, []), - StrippedOpts = filter_src_dirs(ErlOpts), - case rebar_dir:extra_src_dirs(State) of - [] -> rebar_state:set(State, erl_opts, [{src_dirs, ["test"]}|StrippedOpts]); - _ -> rebar_state:set(State, erl_opts, StrippedOpts) - end. - -filter_src_dirs(ErlOpts) -> - lists:filter(fun({src_dirs, _}) -> false; (_) -> true end, ErlOpts). - -test_set(Apps, all) -> set_apps(Apps, []); -test_set(_Apps, Suites) -> set_suites(Suites, []). +test_set(Apps, all) -> {ok, set_apps(Apps, [])}; +test_set(_Apps, Suites) -> {ok, set_suites(Suites, [])}. set_apps([], Acc) -> lists:reverse(Acc); set_apps([App|Rest], Acc) -> |