summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.cirrus.yml42
-rw-r--r--.travis.yml48
-rw-r--r--README.md2
-rwxr-xr-xbootstrap2
-rw-r--r--priv/templates/app.erl10
-rw-r--r--priv/templates/mod.erl10
-rw-r--r--priv/templates/sup.erl33
-rw-r--r--rebar.config9
-rw-r--r--rebar.lock8
-rw-r--r--src/rebar.hrl14
-rw-r--r--src/rebar_app_discover.erl13
-rw-r--r--src/rebar_git_resource.erl28
-rw-r--r--src/rebar_prv_shell.erl43
-rw-r--r--src/rebar_resource_v2.erl3
-rw-r--r--src/rebar_utils.erl14
-rw-r--r--test/rebar_compile_SUITE.erl73
16 files changed, 209 insertions, 143 deletions
diff --git a/.cirrus.yml b/.cirrus.yml
index 11d4229..de7a879 100644
--- a/.cirrus.yml
+++ b/.cirrus.yml
@@ -1,11 +1,12 @@
test_task:
+ use_compute_credits: true
container:
matrix:
+ - image: erlang:22
- image: erlang:21
- image: erlang:20
- image: erlang:19
- image: erlang:18
- - image: erlang:17
test_script: |
./bootstrap
./rebar3 ct
@@ -18,6 +19,45 @@ osx_test_task:
./bootstrap
./rebar3 ct
+nightly_task:
+ container:
+ image: erlang:18
+ depends_on:
+ - test
+ only_if: $BRANCH == "master"
+ script: |
+ apt-get update
+ apt-get install -y s3cmd
+ ./bootstrap
+ s3cmd --access_key=$ACCESS_KEY --secret_key=$SECRET_KEY put ./rebar3 s3://rebar3-nightly
+ environment:
+ ACCESS_KEY: ENCRYPTED[86c639224b3cfc11ae5dbd48b13de5ff77dd5c75f1bf1808ddbbb5bc60049f16885b4e2e3a7981376cac562f7a2d176b]
+ SECRET_KEY: ENCRYPTED[189c3b982c2f846193bb34c3de86e0172b8a4c793699f64dc95bb9a1e6bbe83c252c77d37ea1503928aa9b41a3652ca3]
+
+release_task:
+ container:
+ image: erlang:18
+ depends_on:
+ - test
+ only_if: $CIRRUS_RELEASE != ""
+ script: |
+ apt-get update
+ apt-get install -y s3cmd
+ ./bootstrap
+ s3cmd --access_key=$ACCESS_KEY --secret_key=$SECRET_KEY put ./rebar3 s3://rebar3
+
+ url_to_upload="https://uploads.github.com/repos/$CIRRUS_REPO_FULL_NAME/releases/$CIRRUS_RELEASE/assets?name=rebar3"
+ curl -X POST \
+ --data-binary @rebar3 \
+ --header "Authorization: token $GITHUB_TOKEN" \
+ --header "Content-Type: application/octet-stream" \
+ $url_to_upload
+ environment:
+ ACCESS_KEY: ENCRYPTED[86c639224b3cfc11ae5dbd48b13de5ff77dd5c75f1bf1808ddbbb5bc60049f16885b4e2e3a7981376cac562f7a2d176b]
+ SECRET_KEY: ENCRYPTED[189c3b982c2f846193bb34c3de86e0172b8a4c793699f64dc95bb9a1e6bbe83c252c77d37ea1503928aa9b41a3652ca3]
+ GITUB_TOKEN: ENCRYPTED[ff884c4b0a4f2833b6c22c1fd6398879d58634d0f521e7efbd33f045fb785417f24da953cfbdaee563698501691e5970]
+
+
# Windows CI appears broken for now and never passes
#windows_test_task:
# windows_container:
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 32d51ca..0000000
--- a/.travis.yml
+++ /dev/null
@@ -1,48 +0,0 @@
-language: erlang
-matrix:
- include:
- - os: linux
- otp_release: 17.5
- - os: linux
- otp_release: 18.3
- - os: linux
- otp_release: 19.3
- - os: linux
- otp_release: 20.0
- - os: linux
- otp_release: 21.0
- - os: osx
- language: generic
-before_script:
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update; fi
- ## should eventually use a tap that has previous erlang versions here
- ## as this only uses the latest erlang available via brew
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install erlang; fi
-script: "./bootstrap && ./rebar3 ct"
-branches:
- only:
- - master
- - hex_core
-cache:
- directories:
- - "$HOME/.cache/rebar3/hex/default"
-deploy:
- - provider: releases
- api_key:
- secure: MjloYuaQF3cd3Oab57zqwPDLPqt5MDgBIrRLpXOQwNovr2tnkKd4aJK3QJ3pTxvZievjgl+qIYI1IZyjuRV37nkjAfMw14iig959wi0k8XTJoMdylVxE5X7hk4SiWhX/ycnJx3C28PPw1OitGTF76HAJDMgEelNdoNt+hvjvDEo=
- file: rebar3
- on:
- repo: erlang/rebar3
- tags: true
- - provider: s3
- access_key_id: AKIAJAPYAQEFYCYSNL7Q
- secret_access_key:
- secure: "BUv2KQABv0Q4e8DAVNBRTc/lXHWt27yCN46Fdgo1IrcSSIiP+hq2yXzQcXLbPwkEu6pxUZQtL3mvKbt6l7uw3wFrcRfFAi1PGTITAW8MTmxtwcZIBcHSk3XOzDbkK+fYYcaddszmt7hDzzEFPtmYXiNgnaMIVeynhQLgcCcIRRQ="
- skip_cleanup: true
- local-dir: _build/prod/bin
- bucket: "rebar3-nightly"
- acl: public_read
- on:
- repo: erlang/rebar3
- branch: master
- condition: $TRAVIS_OTP_RELEASE = "17.5"
diff --git a/README.md b/README.md
index 4180a92..8a2168d 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Rebar3
-[![Build Status](https://travis-ci.org/erlang/rebar3.svg?branch=master)](https://travis-ci.org/erlang/rebar3) [![Windows build status](https://ci.appveyor.com/api/projects/status/yx4oitd9pvd2kab3?svg=true)](https://ci.appveyor.com/project/TristanSloughter/rebar3)
+[![Build Status](https://api.cirrus-ci.com/github/erlang/rebar3.svg)](https://cirrus-ci.com/github/erlang/rebar3) [![Windows build status](https://ci.appveyor.com/api/projects/status/yx4oitd9pvd2kab3?svg=true)](https://ci.appveyor.com/project/TristanSloughter/rebar3)
1. [What is Rebar3?](#what-is-rebar3)
2. [Why Rebar3?](#why-rebar3)
diff --git a/bootstrap b/bootstrap
index 094bfe9..e55b3a7 100755
--- a/bootstrap
+++ b/bootstrap
@@ -35,7 +35,7 @@ main(_) ->
bootstrap_rebar3(),
%% Build rebar.app from rebar.app.src
- {ok, App} = rebar_app_info:new(rebar, "3.10.0", filename:absname("_build/default/lib/rebar/")),
+ {ok, App} = rebar_app_info:new(rebar, "3.11.0", filename:absname("_build/default/lib/rebar/")),
rebar_otp_app:compile(rebar_state:new(), App),
%% Because we are compiling files that are loaded already we want to silence
diff --git a/priv/templates/app.erl b/priv/templates/app.erl
index 62d2ddf..80aeca3 100644
--- a/priv/templates/app.erl
+++ b/priv/templates/app.erl
@@ -7,20 +7,12 @@
-behaviour(application).
-%% Application callbacks
-export([start/2, stop/1]).
-%%====================================================================
-%% API
-%%====================================================================
-
start(_StartType, _StartArgs) ->
{{name}}_sup:start_link().
-%%--------------------------------------------------------------------
stop(_State) ->
ok.
-%%====================================================================
-%% Internal functions
-%%====================================================================
+%% internal functions
diff --git a/priv/templates/mod.erl b/priv/templates/mod.erl
index 2f5e09e..05329f0 100644
--- a/priv/templates/mod.erl
+++ b/priv/templates/mod.erl
@@ -1,13 +1,3 @@
-module({{name}}).
-%% API exports
-export([]).
-
-%%====================================================================
-%% API functions
-%%====================================================================
-
-
-%%====================================================================
-%% Internal functions
-%%====================================================================
diff --git a/priv/templates/sup.erl b/priv/templates/sup.erl
index 020021c..42f5511 100644
--- a/priv/templates/sup.erl
+++ b/priv/templates/sup.erl
@@ -8,32 +8,29 @@
-behaviour(supervisor).
-%% API
-export([start_link/0]).
-%% Supervisor callbacks
-export([init/1]).
-define(SERVER, ?MODULE).
-%%====================================================================
-%% API functions
-%%====================================================================
-
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
-%%====================================================================
-%% Supervisor callbacks
-%%====================================================================
-
-%% Child :: #{id => Id, start => {M, F, A}}
-%% Optional keys are restart, shutdown, type, modules.
-%% Before OTP 18 tuples must be used to specify a child. e.g.
-%% Child :: {Id,StartFunc,Restart,Shutdown,Type,Modules}
+%% sup_flags() = #{strategy => strategy(), % optional
+%% intensity => non_neg_integer(), % optional
+%% period => pos_integer()} % optional
+%% child_spec() = #{id => child_id(), % mandatory
+%% start => mfargs(), % mandatory
+%% restart => restart(), % optional
+%% shutdown => shutdown(), % optional
+%% type => worker(), % optional
+%% modules => modules()} % optional
init([]) ->
- {ok, {{one_for_all, 0, 1}, []}}.
+ SupFlags = #{strategy => one_for_all,
+ intensity => 0,
+ period => 1},
+ ChildSpecs = [],
+ {ok, {SupFlags, ChildSpecs}}.
-%%====================================================================
-%% Internal functions
-%%====================================================================
+%% internal functions
diff --git a/rebar.config b/rebar.config
index 6a83a37..aeef226 100644
--- a/rebar.config
+++ b/rebar.config
@@ -2,13 +2,13 @@
%% ex: ts=4 sw=4 ft=erlang et
{deps, [{erlware_commons, "1.3.1"},
- {ssl_verify_fun, "1.1.4"},
+ {ssl_verify_fun, "1.1.5"},
{certifi, "2.5.1"},
{parse_trans, "3.3.0"}, % force otp-21 compat
{providers, "1.7.0"},
{getopt, "1.0.1"},
{bbmustache, "1.6.1"},
- {relx, "3.31.0"},
+ {relx, "3.32.0"},
{cf, "0.2.2"},
{cth_readable, "1.4.4"},
{eunit_formatters, "0.5.0"}]}.
@@ -29,8 +29,7 @@
{escript_incl_extra, [{"relx/priv/templates/*", "_build/default/lib/"},
{"rebar/priv/templates/*", "_build/default/lib/"}]}.
-{erl_opts, [{platform_define, "^[0-9]+", namespaced_types},
- {platform_define, "^(19|2)", rand_only},
+{erl_opts, [{platform_define, "^(19|2)", rand_only},
{platform_define, "^2", unicode_str},
{platform_define, "^(2[1-9])|(20\\\\.3)", filelib_find_source},
{platform_define, "^(R|1|20)", fun_stacktrace},
@@ -45,7 +44,7 @@
%% Profiles
{profiles, [{test, [
- {deps, [{meck, "0.8.12"}]},
+ {deps, [{meck, "0.8.13"}]},
{erl_opts, [debug_info, nowarn_export_all]}
]
},
diff --git a/rebar.lock b/rebar.lock
index 4bcb526..b5ed41a 100644
--- a/rebar.lock
+++ b/rebar.lock
@@ -8,8 +8,8 @@
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.0">>},0},
{<<"providers">>,{pkg,<<"providers">>,<<"1.7.0">>},0},
- {<<"relx">>,{pkg,<<"relx">>,<<"3.31.0">>},0},
- {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.4">>},0}]}.
+ {<<"relx">>,{pkg,<<"relx">>,<<"3.32.0">>},0},
+ {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.5">>},0}]}.
[
{pkg_hash,[
{<<"bbmustache">>, <<"9FB63FA60BD53AFBF47F02E6D8BD6B2BEAFC068E02E20975254DC7461FD4F397">>},
@@ -21,6 +21,6 @@
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
{<<"parse_trans">>, <<"09765507A3C7590A784615CFD421D101AEC25098D50B89D7AA1D66646BC571C1">>},
{<<"providers">>, <<"BBF730563914328EC2511D205E6477A94831DB7297DE313B3872A2B26C562EAB">>},
- {<<"relx">>, <<"7EBA13DFFC4EEA9FBFAE2B42B739AFDE268E07C3EE7207872CD74782A4913455">>},
- {<<"ssl_verify_fun">>, <<"F0EAFFF810D2041E93F915EF59899C923F4568F4585904D010387ED74988E77B">>}]}
+ {<<"relx">>, <<"AE6C9FD6AB5ECFC031E7E7B45BB103CCBBE58C892BD1CDC87DDD38068F6FA733">>},
+ {<<"ssl_verify_fun">>, <<"6EAF7AD16CB568BB01753DBBD7A95FF8B91C7979482B95F38443FE2C8852A79B">>}]}
].
diff --git a/src/rebar.hrl b/src/rebar.hrl
index f11302d..fedf0d0 100644
--- a/src/rebar.hrl
+++ b/src/rebar.hrl
@@ -55,23 +55,9 @@
state :: term(),
implementation :: rebar_resource | rebar_resource_v2}).
--ifdef(namespaced_types).
-type rebar_dict() :: dict:dict().
--else.
--type rebar_dict() :: dict().
--endif.
-
--ifdef(namespaced_types).
-type rebar_digraph() :: digraph:graph().
--else.
--type rebar_digraph() :: digraph().
--endif.
-
--ifdef(namespaced_types).
-type rebar_set() :: sets:set().
--else.
--type rebar_set() :: set().
--endif.
-ifdef(fun_stacktrace).
-define(WITH_STACKTRACE(T, R, S), T:R -> S = erlang:get_stacktrace(),).
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 21dea29..0c97ad7 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -52,7 +52,7 @@ do(State, LibDirs) ->
Name = rebar_app_info:name(AppInfo),
case enable(State, AppInfo) of
true ->
- {AppInfo1, StateAcc1} = merge_opts(AppInfo, StateAcc),
+ {AppInfo1, StateAcc1} = merge_opts(TopLevelApp, AppInfo, StateAcc),
OutDir = filename:join(DepsDir, Name),
AppInfo2 = rebar_app_info:out_dir(AppInfo1, OutDir),
ProjectDeps1 = lists:delete(Name, ProjectDeps),
@@ -91,9 +91,9 @@ format_error({missing_module, Module}) ->
%% some configuration like erl_opts must be merged into a subapp's opts
%% while plugins and hooks need to be kept defined to only either the
%% top level state or an individual application.
--spec merge_opts(rebar_app_info:t(), rebar_state:t()) ->
+-spec merge_opts(root | binary(), rebar_app_info:t(), rebar_state:t()) ->
{rebar_app_info:t(), rebar_state:t()}.
-merge_opts(AppInfo, State) ->
+merge_opts(TopLevelApp, AppInfo, State) ->
%% These steps make sure that hooks and artifacts are run in the context of
%% the application they are defined at. If an umbrella structure is used and
%% they are defined at the top level they will instead run in the context of
@@ -104,7 +104,12 @@ merge_opts(AppInfo, State) ->
Name = rebar_app_info:name(AppInfo1),
%% We reset the opts here to default so no profiles are applied multiple times
- AppInfo2 = rebar_app_info:apply_overrides(rebar_state:get(State1, overrides, []), AppInfo1),
+ AppInfo2 = case TopLevelApp of
+ Name -> % don't apply to the root app
+ AppInfo;
+ _ -> % apply overrides when in an umbrella project or on deps
+ rebar_app_info:apply_overrides(rebar_state:get(State1, overrides, []), AppInfo1)
+ end,
AppInfo3 = rebar_app_info:apply_profiles(AppInfo2, CurrentProfiles),
%% Will throw an exception if checks fail
diff --git a/src/rebar_git_resource.erl b/src/rebar_git_resource.erl
index ac1316b..4e81c05 100644
--- a/src/rebar_git_resource.erl
+++ b/src/rebar_git_resource.erl
@@ -236,7 +236,17 @@ git_vsn_fetch() ->
end.
make_vsn(AppInfo, _) ->
- make_vsn_(rebar_app_info:dir(AppInfo)).
+ Dir = rebar_app_info:dir(AppInfo),
+ case rebar_app_info:original_vsn(AppInfo) of
+ {git, short} ->
+ git_ref(Dir, "--short");
+ {git, long} ->
+ git_ref(Dir, "");
+ _ ->
+ %% already parsed in rebar_utils to get here so we know it
+ %% is either for git or "git"
+ make_vsn_(Dir)
+ end.
make_vsn_(Dir) ->
case collect_default_refcount(Dir) of
@@ -248,6 +258,19 @@ make_vsn_(Dir) ->
%% Internal functions
+git_ref(Dir, Arg) ->
+ case rebar_utils:sh("git rev-parse " ++ Arg ++ " HEAD",
+ [{use_stdout, false},
+ return_on_error,
+ {cd, Dir}]) of
+ {error, _} ->
+ ?WARN("Getting ref of git repo failed in ~ts. "
+ "Falling back to version 0", [Dir]),
+ {plain, "0"};
+ {ok, String} ->
+ {plain, rebar_string:trim(String, both, "\n")}
+ end.
+
collect_default_refcount(Dir) ->
%% Get the tag timestamp and minimal ref from the system. The
%% timestamp is really important from an ordering perspective.
@@ -256,7 +279,8 @@ collect_default_refcount(Dir) ->
return_on_error,
{cd, Dir}]) of
{error, _} ->
- ?WARN("Getting log of git dependency failed in ~ts. Falling back to version 0.0.0", [rebar_dir:get_cwd()]),
+ ?WARN("Getting log of git repo failed in ~ts. "
+ "Falling back to version 0.0.0", [Dir]),
{plain, "0.0.0"};
{ok, String} ->
RawRef = rebar_string:trim(String, both, "\n"),
diff --git a/src/rebar_prv_shell.erl b/src/rebar_prv_shell.erl
index dd3e6f6..406b90a 100644
--- a/src/rebar_prv_shell.erl
+++ b/src/rebar_prv_shell.erl
@@ -88,6 +88,9 @@ init(State) ->
{start_clean, undefined, "start-clean", boolean,
"Cancel any applications in the 'apps' list "
"or release."},
+ {env_file, undefined, "env-file", string,
+ "Path to file of os environment variables to setup "
+ "before expanding vars in config files."},
{user_drv_args, undefined, "user_drv_args", string,
"Arguments passed to user_drv start function for "
"creating custom shells."}]}
@@ -309,6 +312,7 @@ run_script_file(File) ->
Result.
maybe_boot_apps(State) ->
+ _ = maybe_set_env_vars(State),
case find_apps_to_boot(State) of
undefined ->
%% try to read in sys.config file
@@ -577,6 +581,45 @@ consult_env_config(State, Filename) ->
rebar_file_utils:consult_config_terms(State, Terms)
end.
+maybe_set_env_vars(State) ->
+ EnvFile =debug_get_value(env_file, rebar_state:get(State, shell, []), undefined,
+ "Found env_file from config."),
+ {Opts, _} = rebar_state:command_parsed_args(State),
+ EnvFile1 = debug_get_value(env_file, Opts, EnvFile,
+ "Found env_file from command line option."),
+
+ case maybe_read_file(EnvFile1) of
+ ignore ->
+ ok;
+ {error, _} ->
+ ?WARN("Failed to read file with environment variables: ~p", [EnvFile1]);
+ {ok, Bin} ->
+ Lines = string:split(unicode:characters_to_list(Bin), "\n", all),
+ [handle_env_var_line(Line) || Line <- Lines]
+ end.
+
+handle_env_var_line(Line) ->
+ Trimmed = rebar_string:trim(Line, both, [$\s]),
+ %% ignore lines starting with # and
+ %% fail if there are spaces around =
+ case re:run(Trimmed, "^(?<key>[^#][^\s=]*)=(?<value>[^\s]\.*)",
+ [{capture, [key, value], list}, unicode]) of
+ {match, [Key, Value]} ->
+ os:putenv(Key, Value);
+ _ ->
+ case Trimmed of
+ [$# | _] -> ignore;
+ [] -> ignore;
+ Other ->
+ ?WARN("Unable to parse environment variable from this line: ~ts", [Other])
+ end
+ end.
+
+maybe_read_file(undefined) ->
+ ignore;
+maybe_read_file(EnvFile) ->
+ file:read_file(EnvFile).
+
%% @doc quick and simple variable substitution writeup.
%% Supports `${varname}' but not `$varname' nor nested
%% values such as `${my_${varname}}'.
diff --git a/src/rebar_resource_v2.erl b/src/rebar_resource_v2.erl
index b7ee760..537b5f0 100644
--- a/src/rebar_resource_v2.erl
+++ b/src/rebar_resource_v2.erl
@@ -101,7 +101,8 @@ needs_update(AppInfo, State) ->
resource_run(needs_update, rebar_app_info:source(AppInfo), [AppInfo], State).
%% this is a special case since it is used for project apps as well, not just deps
-make_vsn(AppInfo, VcsType, State) ->
+make_vsn(AppInfo, Vsn, State) ->
+ VcsType = case Vsn of {T, _} -> T; T -> T end,
Resources = rebar_state:resources(State),
case is_resource_type(VcsType, Resources) of
true ->
diff --git a/src/rebar_utils.erl b/src/rebar_utils.erl
index f1e440a..066c673 100644
--- a/src/rebar_utils.erl
+++ b/src/rebar_utils.erl
@@ -460,7 +460,7 @@ reread_config(ConfigList, Opts) ->
%% NB: we attempt to mimic -config here, which survives app reload,
%% hence {persistent, true}.
SetEnv = case version_tuple(?MODULE:otp_release()) of
- {X, _, _} when X =< 17 ->
+ {X, _, _} when X < 17 ->
fun application:set_env/3;
_ ->
fun (App, Key, Val) -> application:set_env(App, Key, Val, [{persistent, true}]) end
@@ -729,7 +729,7 @@ vcs_vsn(AppInfo, Vcs, State) ->
{plain, VsnString} ->
VsnString;
{cmd, CmdString} ->
- vcs_vsn_invoke(CmdString, rebar_app_info:dir(AppInfo));
+ cmd_vsn_invoke(CmdString, rebar_app_info:dir(AppInfo));
unknown ->
?ABORT("vcs_vsn: Unknown vsn format: ~p", [Vcs]);
{error, Reason} ->
@@ -743,8 +743,14 @@ vcs_vsn_cmd(AppInfo, VCS, State) when VCS =:= semver ; VCS =:= "semver" ->
vcs_vsn_cmd(AppInfo, git, State);
vcs_vsn_cmd(_AppInfo, {cmd, _Cmd}=Custom, _) ->
Custom;
+vcs_vsn_cmd(AppInfo, {file, File}, _) ->
+ Path = filename:join(rebar_app_info:dir(AppInfo), File),
+ {ok, Vsn} = file:read_file(Path),
+ {plain, to_list(rebar_string:trim(Vsn))};
vcs_vsn_cmd(AppInfo, VCS, State) when is_atom(VCS) ->
rebar_resource_v2:make_vsn(AppInfo, VCS, State);
+vcs_vsn_cmd(AppInfo, {VCS, _}=V, State) when is_atom(VCS) ->
+ rebar_resource_v2:make_vsn(AppInfo, V, State);
vcs_vsn_cmd(AppInfo, VCS, State) when is_list(VCS) ->
try list_to_existing_atom(VCS) of
AVCS ->
@@ -759,7 +765,7 @@ vcs_vsn_cmd(AppInfo, VCS, State) when is_list(VCS) ->
vcs_vsn_cmd(_, _, _) ->
unknown.
-vcs_vsn_invoke(Cmd, Dir) ->
+cmd_vsn_invoke(Cmd, Dir) ->
{ok, VsnString} = rebar_utils:sh(Cmd, [{cd, Dir}, {use_stdout, false}]),
rebar_string:trim(VsnString, trailing, "\n").
@@ -966,7 +972,7 @@ get_proxy_auth() ->
{ok, ProxyAuth} -> ProxyAuth
end.
--spec rebar_utils:is_list_of_strings(term()) -> boolean().
+-spec is_list_of_strings(term()) -> boolean().
is_list_of_strings(List) when not is_list(hd(List)) ->
false;
is_list_of_strings(List) when is_list(hd(List)) ->
diff --git a/test/rebar_compile_SUITE.erl b/test/rebar_compile_SUITE.erl
index 44f20d7..8389ebc 100644
--- a/test/rebar_compile_SUITE.erl
+++ b/test/rebar_compile_SUITE.erl
@@ -27,7 +27,7 @@ all() ->
profile_deps, deps_build_in_prod, only_deps,
override_deps, override_add_deps, override_del_deps,
override_opts, override_add_opts, override_del_opts,
- apply_overrides_exactly_once,
+ apply_overrides_exactly_once, override_only_deps,
profile_override_deps, profile_override_add_deps, profile_override_del_deps,
profile_override_opts, profile_override_add_opts, profile_override_del_opts,
include_file_relative_to_working_directory, include_file_in_src,
@@ -1442,10 +1442,11 @@ override_del_deps(Config) ->
).
override_opts(Config) ->
- AppDir = ?config(apps, Config),
+ AppsDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
@@ -1460,12 +1461,12 @@ override_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "default", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
@@ -1502,7 +1503,7 @@ apply_overrides_exactly_once(Config) ->
rebar_test_utils:run_and_check(
Config, RebarConfig, ["ct", "--compile_only"], {ok, [{app, Name}, {dep, "some_dep"}], "test"}).
-override_add_opts(Config) ->
+override_only_deps(Config) ->
AppDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
@@ -1510,6 +1511,30 @@ override_add_opts(Config) ->
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
+ {deps, []}, %% with deps enabled, this test fails
+ {overrides, [
+ {add, [
+ {erl_opts, [{d, bad, a}, {d, bad, b}]}
+ ]}
+ ]}
+ ],
+
+ rebar_test_utils:create_config(AppDir, RebarConfig),
+
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
+
+ ok.
+
+override_add_opts(Config) ->
+ AppsDir = ?config(apps, Config),
+
+ Name = rebar_test_utils:create_random_name("app1_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [
{erl_opts, [
warn_missing_spec
]},
@@ -1520,12 +1545,12 @@ override_add_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "default", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
@@ -1534,10 +1559,11 @@ override_add_opts(Config) ->
true = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])).
override_del_opts(Config) ->
- AppDir = ?config(apps, Config),
+ AppsDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
@@ -1552,18 +1578,19 @@ override_del_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "default", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "default", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
true = lists:member(compressed, proplists:get_value(options, Mod:module_info(compile), [])),
- false = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])).
+ false = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])),
+ ok.
profile_override_deps(Config) ->
Deps = rebar_test_utils:expand_deps(git, [{"some_dep", "0.0.1", [{"other_dep", "0.0.1", []}]}]),
@@ -1665,10 +1692,11 @@ profile_override_del_deps(Config) ->
).
profile_override_opts(Config) ->
- AppDir = ?config(apps, Config),
+ AppsDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
@@ -1687,12 +1715,12 @@ profile_override_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["as", "a", "compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "a", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "a", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
@@ -1701,10 +1729,11 @@ profile_override_opts(Config) ->
false = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])).
profile_override_add_opts(Config) ->
- AppDir = ?config(apps, Config),
+ AppsDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
@@ -1722,12 +1751,12 @@ profile_override_add_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["as", "a", "compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "a", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "a", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
@@ -1736,10 +1765,11 @@ profile_override_add_opts(Config) ->
true = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])).
profile_override_del_opts(Config) ->
- AppDir = ?config(apps, Config),
+ AppsDir = ?config(apps, Config),
Name = rebar_test_utils:create_random_name("app1_"),
Vsn = rebar_test_utils:create_random_vsn(),
+ AppDir = filename:join([AppsDir, "apps", Name]),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
RebarConfig = [
@@ -1758,18 +1788,19 @@ profile_override_del_opts(Config) ->
]}
],
- rebar_test_utils:create_config(AppDir, RebarConfig),
+ rebar_test_utils:create_config(AppsDir, RebarConfig),
rebar_test_utils:run_and_check(
Config, RebarConfig, ["as", "a", "compile"], {ok, [{app, Name}]}),
- Path = filename:join([AppDir, "_build", "a", "lib", Name, "ebin"]),
+ Path = filename:join([AppsDir, "_build", "a", "lib", Name, "ebin"]),
code:add_patha(Path),
Mod = list_to_atom("not_a_real_src_" ++ Name),
true = lists:member(compressed, proplists:get_value(options, Mod:module_info(compile), [])),
- false = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])).
+ false = lists:member(warn_missing_spec, proplists:get_value(options, Mod:module_info(compile), [])),
+ ok.
profile_deps(Config) ->
Deps = rebar_test_utils:expand_deps(git, [{"some_dep", "0.0.1", [{"other_dep", "0.0.1", []}]}]),