summaryrefslogtreecommitdiff
path: root/test/rebar_test_utils.erl
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2018-09-21 10:32:57 -0600
committerGitHub <noreply@github.com>2018-09-21 10:32:57 -0600
commit2dfba204e4dea5d1c3821fd26d22bd7201595f6c (patch)
tree147f7ab179d3342bc06d106e188d5c62637bc3ec /test/rebar_test_utils.erl
parent8e0ef83de48968fed80114cc4518004ed59fa649 (diff)
properly support top level app erl_opts from REBAR_CONFIG os var (#1889)
When REBAR_CONFIG was set it would not effect the top level app's configuration because app_discover was rereading the top level rebar.config which ignored REBAR_CONFIG. Instead this patch has it use the existing configuration from REBAR_CONFIG.
Diffstat (limited to 'test/rebar_test_utils.erl')
-rw-r--r--test/rebar_test_utils.erl29
1 files changed, 28 insertions, 1 deletions
diff --git a/test/rebar_test_utils.erl b/test/rebar_test_utils.erl
index efe7467..944efa0 100644
--- a/test/rebar_test_utils.erl
+++ b/test/rebar_test_utils.erl
@@ -1,7 +1,7 @@
-module(rebar_test_utils).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
--export([init_rebar_state/1, init_rebar_state/2, run_and_check/4, check_results/3]).
+-export([init_rebar_state/1, init_rebar_state/2, run_and_check/3, run_and_check/4, check_results/3]).
-export([expand_deps/2, flat_deps/1, top_level_deps/1]).
-export([create_app/4, create_plugin/4, create_eunit_app/4, create_empty_app/4,
create_config/2, create_config/3, package_app/4]).
@@ -82,6 +82,33 @@ run_and_check(Config, RebarConfig, Command, Expect) ->
rebar_abort when Expect =:= rebar_abort -> rebar_abort
end.
+run_and_check(Config, Command, Expect) ->
+ %% Assumes init_rebar_state has run first
+ AppDir = ?config(apps, Config),
+ {ok, Cwd} = file:get_cwd(),
+ try
+ ok = file:set_cwd(AppDir),
+ Res = rebar3:run(Command),
+ case Expect of
+ {error, Reason} ->
+ ?assertEqual({error, Reason}, Res);
+ {ok, Expected} ->
+ {ok, _} = Res,
+ check_results(AppDir, Expected, "*"),
+ Res;
+ {ok, Expected, ProfileRun} ->
+ {ok, _} = Res,
+ check_results(AppDir, Expected, ProfileRun),
+ Res;
+ return ->
+ Res
+ end
+ catch
+ rebar_abort when Expect =:= rebar_abort -> rebar_abort
+ after
+ ok = file:set_cwd(Cwd)
+ end.
+
%% @doc Creates a dummy application including:
%% - src/<file>.erl
%% - src/<file>.app.src