浏览代码

Failing case for unstable upgrade lock files

pull/602/head
Fred Hebert 9 年前
提交者 Tristan Sloughter
父节点
当前提交
81bf52501d
共有 2 个文件被更改,包括 35 次插入5 次删除
  1. +3
    -3
      test/rebar_test_utils.erl
  2. +32
    -2
      test/rebar_upgrade_SUITE.erl

+ 3
- 3
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)). ok = ec_file:write_term(Filename, get_app_metadata(ec_cnv:to_list(Name), Version, Deps)).
erl_src_file(Name) -> erl_src_file(Name) ->
io_lib:format("-module(~s).\n"
io_lib:format("-module('~s').\n"
"-export([main/0]).\n" "-export([main/0]).\n"
"main() -> ok.\n", [filename:basename(Name, ".erl")]). "main() -> ok.\n", [filename:basename(Name, ".erl")]).
erl_eunitized_src_file(Name) -> erl_eunitized_src_file(Name) ->
io_lib:format("-module(~s).\n"
io_lib:format("-module('~s').\n"
"-export([main/0]).\n" "-export([main/0]).\n"
"main() -> ok.\n" "main() -> ok.\n"
"-ifdef(TEST).\n" "-ifdef(TEST).\n"
@ -348,7 +348,7 @@ erl_eunitized_src_file(Name) ->
erl_eunit_suite_file(Name) -> erl_eunit_suite_file(Name) ->
BaseName = filename:basename(Name, ".erl"), BaseName = filename:basename(Name, ".erl"),
io_lib:format("-module(~s_tests).\n"
io_lib:format("-module('~s_tests').\n"
"-compile(export_all).\n" "-compile(export_all).\n"
"-ifndef(some_define).\n" "-ifndef(some_define).\n"
"-define(some_define, false).\n" "-define(some_define, false).\n"

+ 32
- 2
test/rebar_upgrade_SUITE.erl 查看文件

@ -10,7 +10,8 @@ groups() ->
pair_a, pair_b, pair_ab, pair_c, pair_all, pair_a, pair_b, pair_ab, pair_c, pair_all,
triplet_a, triplet_b, triplet_c, triplet_a, triplet_b, triplet_c,
tree_a, tree_b, tree_c, tree_c2, tree_ac, tree_all, 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}]}, {git, [], [{group, all}]},
{pkg, [], [{group, all}]}]. {pkg, [], [{group, all}]}].
@ -404,7 +405,20 @@ upgrades(fwd_lock) ->
%% file to include the result post-upgrade, and then %% file to include the result post-upgrade, and then
%% run a regular lock to see that the lock file is respected %% run a regular lock to see that the lock file is respected
%% in deps. %% 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 %% TODO: add a test that verifies that unlocking files and then
%% running the upgrade code is enough to properly upgrade things. %% running the upgrade code is enough to properly upgrade things.
@ -518,6 +532,22 @@ fwd_lock(Config) ->
Config, NewRebarConfig, ["lock", App], Expectation 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) -> run(Config) ->
apply(?config(mock, Config), []), apply(?config(mock, Config), []),
{ok, RebarConfig} = file:consult(?config(rebarconfig, Config)), {ok, RebarConfig} = file:consult(?config(rebarconfig, Config)),

正在加载...
取消
保存