From 33e4b7e0173556bf97bfe1bbeb9d2a27bb5573fb Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 14 Nov 2014 09:29:55 -0600 Subject: add cleanup_code_path back to rebar_utils for eunit provider --- src/rebar_utils.erl | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl index 3309c24..9a0e1d9 100644 --- a/src/rebar_utils.erl +++ b/src/rebar_utils.erl @@ -54,7 +54,8 @@ ebin_dir/0, processing_base_dir/1, processing_base_dir/2, - indent/1]). + indent/1, + cleanup_code_path/1]). %% for internal use only -export([otp_release/0]). @@ -542,3 +543,17 @@ filter_defines([Opt | Rest], Acc) -> -spec indent(non_neg_integer()) -> iolist(). indent(Amount) when erlang:is_integer(Amount) -> [?ONE_LEVEL_INDENT || _ <- lists:seq(1, Amount)]. + +cleanup_code_path(OrigPath) -> + CurrentPath = code:get_path(), + AddedPaths = CurrentPath -- OrigPath, + %% If someone has removed paths, it's hard to get them back into + %% the right order, but since this is currently rare, we can just + %% fall back to code:set_path/1. + case CurrentPath -- AddedPaths of + OrigPath -> + _ = [code:del_path(Path) || Path <- AddedPaths], + true; + _ -> + code:set_path(OrigPath) + end. -- cgit v1.1