summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2015-02-11 20:06:49 +0000
committerFred Hebert <mononcqc@ferd.ca>2015-02-11 21:57:58 +0000
commit6d8567a7edbf206a0f595c22ecd17af0c46acb87 (patch)
tree5a64739e117bd077345f815936a7168c2bb6d6ba /test
parent62dc8fa9c745cca60f45ad301e05c8b70517626c (diff)
Support multiple app upgrade & lock tests
- Many apps is supported through and through - Not mentioning any app upgrades all apps - Locks are refreshed on disk and tested as such after an upgrade
Diffstat (limited to 'test')
-rw-r--r--test/rebar_test_utils.erl14
-rw-r--r--test/rebar_upgrade_SUITE.erl41
2 files changed, 50 insertions, 5 deletions
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index 827d134..96200a6 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -103,6 +103,8 @@ create_random_vsn() ->
check_results(AppDir, Expected) ->
BuildDir = filename:join([AppDir, "_build", "lib"]),
CheckoutsDir = filename:join([AppDir, "_checkouts"]),
+ LockFile = filename:join([AppDir, "rebar.lock"]),
+ Locks = lists:flatten(rebar_config:consult_file(LockFile)),
Apps = rebar_app_discover:find_apps([AppDir]),
InvalidApps = rebar_app_discover:find_apps([AppDir], invalid),
ValidApps = rebar_app_discover:find_apps([AppDir], valid),
@@ -153,6 +155,18 @@ check_results(AppDir, Expected) ->
?assertEqual(iolist_to_binary(Vsn),
iolist_to_binary(rebar_app_info:original_vsn(App)))
end
+ ; ({lock, Name}) ->
+ ct:pal("Name: ~p", [Name]),
+ ?assertNotEqual(false, lists:keyfind(iolist_to_binary(Name), 1, Locks))
+ ; ({lock, Name, Vsn}) ->
+ ct:pal("Name: ~p, Vsn: ~p", [Name, Vsn]),
+ case lists:keyfind(iolist_to_binary(Name), 1, Locks) of
+ false ->
+ error({lock_not_found, Name});
+ {_LockName, {_, _, {ref, LockVsn}}, _} ->
+ ?assertEqual(iolist_to_binary(Vsn),
+ iolist_to_binary(LockVsn))
+ end
end, Expected).
write_src_file(Dir, Name) ->
diff --git a/test/rebar_upgrade_SUITE.erl b/test/rebar_upgrade_SUITE.erl
index 6491527..e0bb011 100644
--- a/test/rebar_upgrade_SUITE.erl
+++ b/test/rebar_upgrade_SUITE.erl
@@ -7,9 +7,9 @@ all() -> [{group, git}].%, {group, pkg}].
groups() ->
[{all, [], [top_a, top_b, top_c, top_d1, top_d2, top_e,
- pair_a, pair_b, pair_ab, pair_c,
+ pair_a, pair_b, pair_ab, pair_c, pair_all,
triplet_a, triplet_b, triplet_c,
- tree_a, tree_b, tree_c, tree_c2, tree_ac]},
+ tree_a, tree_b, tree_c, tree_c2, tree_ac, tree_all]},
{git, [], [{group, all}]},
{pkg, [], [{group, all}]}].
@@ -172,6 +172,15 @@ upgrades(pair_c) ->
],
["A","B","C","D"],
{"C", {error, {transitive_dependency, <<"C">>}}}};
+upgrades(pair_all) ->
+ {[{"A", "1", [{"C", "1", []}]},
+ {"B", "1", [{"D", "1", []}]}
+ ],
+ [{"A", "2", [{"C", "2", []}]},
+ {"B", "2", [{"D", "2", []}]}
+ ],
+ ["A","B","C","D"],
+ {"", [{"A","2"},{"C","2"},{"B","2"},{"D","2"}]}};
upgrades(triplet_a) ->
{[{"A", "1", [{"D",[]},
{"E","3",[]}]},
@@ -313,7 +322,25 @@ upgrades(tree_ac) ->
["C","I"],
{"C, A", [{"A","1"}, "D", "J", "E", {"I","1"},
{"B","1"}, "F", "G",
- {"C","1"}, "H"]}}.
+ {"C","1"}, "H"]}};
+upgrades(tree_all) ->
+ {[{"A", "1", [{"D",[{"J",[]}]},
+ {"E",[{"I","1",[]}]}]},
+ {"B", "1", [{"F",[]},
+ {"G",[]}]},
+ {"C", "1", [{"H",[]},
+ {"I","2",[]}]}
+ ],
+ [{"A", "1", [{"D",[{"J",[]}]},
+ {"E",[{"I","1",[]}]}]},
+ {"B", "1", [{"F",[]},
+ {"G",[]}]},
+ {"C", "1", [{"H",[]}]}
+ ],
+ ["C","I"],
+ {"", [{"A","1"}, "D", "J", "E", {"I","1"},
+ {"B","1"}, "F", "G",
+ {"C","1"}, "H"]}}.
%% TODO: add a test that verifies that unlocking files and then
%% running the upgrade code is enough to properly upgrade things.
@@ -377,10 +404,12 @@ normalize_unlocks_expect({error, Reason}) ->
normalize_unlocks_expect([]) ->
[];
normalize_unlocks_expect([{App,Vsn} | Rest]) ->
- [{dep, App, Vsn}
+ [{dep, App, Vsn},
+ {lock, App, Vsn}
| normalize_unlocks_expect(Rest)];
normalize_unlocks_expect([App | Rest]) ->
- [{dep, App} | normalize_unlocks_expect(Rest)].
+ [{dep, App},
+ {lock, App} | normalize_unlocks_expect(Rest)].
top_a(Config) -> run(Config).
top_b(Config) -> run(Config).
@@ -393,6 +422,7 @@ pair_a(Config) -> run(Config).
pair_b(Config) -> run(Config).
pair_ab(Config) -> run(Config).
pair_c(Config) -> run(Config).
+pair_all(Config) -> run(Config).
triplet_a(Config) -> run(Config).
triplet_b(Config) -> run(Config).
@@ -403,6 +433,7 @@ tree_b(Config) -> run(Config).
tree_c(Config) -> run(Config).
tree_c2(Config) -> run(Config).
tree_ac(Config) -> run(Config).
+tree_all(Config) -> run(Config).
run(Config) ->
apply(?config(mock, Config), []),