summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralisdair sullivan <alisdair.sullivan@askuity.com>2016-03-01 15:05:45 -0800
committeralisdair sullivan <alisdair.sullivan@askuity.com>2016-03-01 15:07:56 -0800
commit1d5f520deb0bf277bbe21dc63b76236b180fdbd0 (patch)
treea0fe8f0f395b09f7d6dc4e2da58c8c4da2ed9a5f /test
parent5a3676417038dde234993006924580a14805d8bd (diff)
add support for common tests `include` flag
Diffstat (limited to 'test')
-rw-r--r--test/rebar_ct_SUITE.erl30
1 files changed, 27 insertions, 3 deletions
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index 94ab690..9532b15 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -38,6 +38,7 @@
cmd_multiply_timetraps/1,
cmd_scale_timetraps/1,
cmd_create_priv_dir/1,
+ cmd_include_dir/1,
cfg_opts/1,
cfg_arbitrary_opts/1,
cfg_test_spec/1,
@@ -95,7 +96,8 @@ groups() -> [{basic_app, [], [basic_app_default_dirs,
cmd_abort_if_missing_suites,
cmd_multiply_timetraps,
cmd_scale_timetraps,
- cmd_create_priv_dir]},
+ cmd_create_priv_dir,
+ cmd_include_dir]},
{cover, [], [cover_compiled]}].
init_per_group(basic_app, Config) ->
@@ -211,7 +213,7 @@ init_per_group(ct_opts, Config) ->
{ok, State} = rebar_test_utils:run_and_check(C, [], ["as", "test", "lock"], return),
- [{result, State}|C];
+ [{result, State}, {name, Name}|C];
init_per_group(cover, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_opts"),
@@ -700,7 +702,6 @@ suite_at_app_root(Config) ->
data_dir_correct(Config) ->
DataDir = ?config(data_dir, Config),
Parts = filename:split(DataDir),
- ct:pal(Parts),
["rebar_ct_SUITE_data","test","rebar","lib","test","_build"|_] = lists:reverse(Parts).
cmd_label(Config) ->
@@ -973,6 +974,29 @@ cmd_create_priv_dir(Config) ->
true = lists:member({create_priv_dir, manual_per_tc}, TestOpts).
+cmd_include_dir(Config) ->
+ State = ?config(result, Config),
+ AppDir = ?config(apps, Config),
+
+ Providers = rebar_state:providers(State),
+ Namespace = rebar_state:namespace(State),
+ CommandProvider = providers:get_provider(ct, Providers, Namespace),
+ GetOptSpec = providers:opts(CommandProvider),
+ {ok, GetOptResult} = getopt:parse(GetOptSpec, ["--include=foo/bar/baz,qux"]),
+
+ NewState = rebar_state:command_parsed_args(State, GetOptResult),
+
+ Tests = rebar_prv_common_test:prepare_tests(NewState),
+ {ok, _} = rebar_prv_common_test:compile(NewState, Tests),
+
+ Name = ?config(name, Config),
+ Beam = filename:join([AppDir, "_build", "test", "lib", Name, "ebin", Name ++ ".beam"]),
+
+ {ok, {_, [{compile_info, Info}]}} = beam_lib:chunks(Beam, [compile_info]),
+ CompileOpts = proplists:get_value(options, Info),
+ true = lists:member({i, "foo/bar/baz"}, CompileOpts),
+ true = lists:member({i, "qux"}, CompileOpts).
+
cfg_opts(Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_opts_"),