diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-07-09 01:45:46 +0000 |
---|---|---|
committer | Tristan Sloughter <t@crashfast.com> | 2015-07-08 20:51:30 -0500 |
commit | 81bf52501dcf0c3f783a32429733bea487e53933 (patch) | |
tree | 82a8f173c2fd446d4f0c7912180d24c2db520c4d /test | |
parent | 3716c347a5d6c297ab628cce697ae38052d2bb0b (diff) |
Failing case for unstable upgrade lock files
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_test_utils.erl | 6 | ||||
-rw-r--r-- | test/rebar_upgrade_SUITE.erl | 34 |
2 files changed, 35 insertions, 5 deletions
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl index e59ca23..4a13e03 100644 --- a/test/rebar_test_utils.erl +++ b/test/rebar_test_utils.erl @@ -333,12 +333,12 @@ write_app_src_file(Dir, Name, Version, Deps) -> ok = ec_file:write_term(Filename, get_app_metadata(ec_cnv:to_list(Name), Version, Deps)). erl_src_file(Name) -> - io_lib:format("-module(~s).\n" + io_lib:format("-module('~s').\n" "-export([main/0]).\n" "main() -> ok.\n", [filename:basename(Name, ".erl")]). erl_eunitized_src_file(Name) -> - io_lib:format("-module(~s).\n" + io_lib:format("-module('~s').\n" "-export([main/0]).\n" "main() -> ok.\n" "-ifdef(TEST).\n" @@ -348,7 +348,7 @@ erl_eunitized_src_file(Name) -> erl_eunit_suite_file(Name) -> BaseName = filename:basename(Name, ".erl"), - io_lib:format("-module(~s_tests).\n" + io_lib:format("-module('~s_tests').\n" "-compile(export_all).\n" "-ifndef(some_define).\n" "-define(some_define, false).\n" diff --git a/test/rebar_upgrade_SUITE.erl b/test/rebar_upgrade_SUITE.erl index 79cf29e..f2d4133 100644 --- a/test/rebar_upgrade_SUITE.erl +++ b/test/rebar_upgrade_SUITE.erl @@ -10,7 +10,8 @@ groups() -> 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_all, - delete_d, promote, stable_lock, fwd_lock]}, + delete_d, promote, stable_lock, fwd_lock, + compile_upgrade_parity]}, {git, [], [{group, all}]}, {pkg, [], [{group, all}]}]. @@ -404,7 +405,20 @@ upgrades(fwd_lock) -> %% file to include the result post-upgrade, and then %% run a regular lock to see that the lock file is respected %% in deps. - {"any", [{"A","2"},{"C","2"},{"B","2"},{"D","2"}]}}. + {"any", [{"A","2"},{"C","2"},{"B","2"},{"D","2"}]}}; +upgrades(compile_upgrade_parity) -> + {[{"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"]}}. %% TODO: add a test that verifies that unlocking files and then %% running the upgrade code is enough to properly upgrade things. @@ -518,6 +532,22 @@ fwd_lock(Config) -> Config, NewRebarConfig, ["lock", App], Expectation ). +compile_upgrade_parity(Config) -> + AppDir = ?config(apps, Config), + apply(?config(mock, Config), []), + {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), + %% compiling and upgrading should generate the same lockfiles when + %% deps are identical + Lockfile = filename:join([AppDir, "rebar.lock"]), + rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, []}), + {ok, CompileLockData1} = file:read_file(Lockfile), + rebar_test_utils:run_and_check(Config, RebarConfig, ["upgrade"], {ok, []}), + {ok, UpgradeLockData} = file:read_file(Lockfile), + rebar_test_utils:run_and_check(Config, RebarConfig, ["compile"], {ok, []}), + {ok, CompileLockData2} = file:read_file(Lockfile), + ?assertEqual(CompileLockData1, CompileLockData2), + ?assertEqual(CompileLockData1, UpgradeLockData). + run(Config) -> apply(?config(mock, Config), []), {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), |