瀏覽代碼

Fix lock file not being generated when no deps are present in the config

pull/2353/head
Pablo Costas 4 年之前
父節點
當前提交
e65ef19194
共有 2 個文件被更改,包括 27 次插入2 次删除
  1. +4
    -1
      src/rebar_config.erl
  2. +23
    -1
      test/rebar_deps_SUITE.erl

+ 4
- 1
src/rebar_config.erl 查看文件

@ -119,7 +119,10 @@ maybe_write_lock_file(LockFile, Locks, Locks) ->
Terms = consult_file_(LockFile),
case Terms of
[] ->
ok;
case filelib:is_regular(LockFile) of
true -> ok;
false -> write_lock_file(LockFile, Locks)
end;
[{?CONFIG_VERSION, FileLocks}|_] when is_list(FileLocks) ->
ok;
_ ->

+ 23
- 1
test/rebar_deps_SUITE.erl 查看文件

@ -3,7 +3,7 @@
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
all() -> [sub_app_deps, newly_added_dep, newly_added_after_empty_lock,
all() -> [sub_app_deps, newly_added_dep, newly_added_after_empty_lock, no_deps_empty_lock,
http_proxy_settings, https_proxy_settings,
http_os_proxy_settings, https_os_proxy_settings,
semver_matching_lt, semver_matching_lte, semver_matching_gt,
@ -45,6 +45,8 @@ init_per_testcase(semver_matching_gt, Config) ->
rebar_test_utils:init_rebar_state(Config);
init_per_testcase(newly_added_after_empty_lock, Config) ->
rebar_test_utils:init_rebar_state(Config);
init_per_testcase(no_deps_empty_lock, Config) ->
rebar_test_utils:init_rebar_state(Config);
init_per_testcase(newly_added_dep, Config) ->
rebar_test_utils:init_rebar_state(Config);
init_per_testcase(sub_app_deps, Config) ->
@ -384,6 +386,26 @@ newly_added_after_empty_lock(Config) ->
Config, RebarConfig3, ["compile"],
{ok, [{app, Name}, {dep, "a", "1.0.0"}]}).
no_deps_empty_lock(Config) ->
AppDir = ?config(apps, Config),
Deps = rebar_test_utils:expand_deps(git, []),
mock_git_resource:mock([{deps, Deps}]),
{ok, RebarConfig} = file:consult(rebar_test_utils:create_config(AppDir, [{deps, Deps}])),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["compile"],
{ok, []}),
LockFile = filename:join(AppDir, "rebar.lock"),
%% the lock file should exist
{ok,_} = file:read_file_info(LockFile),
%% and just in case, it should be empty
?assertEqual([], rebar_config:consult_lock_file(LockFile)),
%% which means that merging that lock file with the current config
%% returns the same config
?assertEqual(RebarConfig, rebar_config:merge_locks(RebarConfig,
rebar_config:consult_lock_file(LockFile))).
http_proxy_settings(_Config) ->
%% Load config

Loading…
取消
儲存