summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2018-10-08 12:41:30 -0400
committerFred Hebert <mononcqc@ferd.ca>2018-10-11 08:43:54 -0400
commitaf5cecd8eec9692f43d04ad53c8f28734012b873 (patch)
tree5106e03489cc201f7c055368be0c82abbf171dcd /test
parent311ee6b1371c3eea3611dc5d7945b1b5667c75bd (diff)
Clean path code, add tests, add clash detection
Some finishing touch to that code
Diffstat (limited to 'test')
-rw-r--r--test/rebar_paths_SUITE.erl37
1 files changed, 34 insertions, 3 deletions
diff --git a/test/rebar_paths_SUITE.erl b/test/rebar_paths_SUITE.erl
index 48a7000..f2832c0 100644
--- a/test/rebar_paths_SUITE.erl
+++ b/test/rebar_paths_SUITE.erl
@@ -4,11 +4,16 @@
-compile(export_all).
all() ->
- [%clashing_apps,
+ [clashing_apps,
check_modules,
- set_paths
+ set_paths,
+ misloaded_mods
].
+%%%%%%%%%%%%%%%%%%
+%%% TEST SETUP %%%
+%%%%%%%%%%%%%%%%%%
+
init_per_testcase(Case, Config) ->
BasePaths = code:get_path(),
%% This test checks that the right module sets get loaded; however, we must
@@ -90,13 +95,17 @@ compile_fake_appmod(App) ->
{ok, _, Bin} = compile:forms(Mod),
ok = file:write_file(filename:join([OutDir, <<Name/binary, ".beam">>]), Bin).
+%%%%%%%%%%%%%
+%%% TESTS %%%
+%%%%%%%%%%%%%
+
clashing_apps(Config) ->
Clashes = rebar_paths:clashing_apps([deps, plugins],
?config(state, Config)),
ct:pal("Clashes: ~p", [Clashes]),
?assertEqual([<<"relx">>, <<"rp_a">>], lists:sort(proplists:get_value(deps, Clashes))),
- ?assertEqual(undefined, proplists:get_value(plugins, Clashes)),
+ ?assertEqual([], proplists:get_value(plugins, Clashes)),
ok.
set_paths(Config) ->
@@ -201,6 +210,28 @@ check_modules(Config) ->
?assertEqual(3, length(relx:module_info(exports))), % can't replace bundled
ok.
+misloaded_mods(_Config) ->
+ Res = rebar_paths:misloaded_modules(
+ [a,b,c,d,e,f],
+ ["/1/2/3/4",
+ "/1/2/4",
+ "/2/1/1",
+ "/3/4/5"],
+ [{a, "/0/1/2/file.beam"},
+ {aa, "/1/2/3/4/file.beam"},
+ {b, "/1/2/3/4/file.beam"},
+ {c, "/2/1/file.beam"},
+ {f, preloaded},
+ {d, "/3/5/7/file.beam"},
+ {e, "/3/4/5/file.beam"}]
+ ),
+ ?assertEqual([a,c,d], Res),
+ ok.
+
+%%%%%%%%%%%%%%%
+%%% HELPERS %%%
+%%%%%%%%%%%%%%%
+
find_first_instance(Frag, []) ->
{not_found, Frag};
find_first_instance(Frag, [Path|Rest]) ->