summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoralisdair sullivan <alisdair.sullivan@askuity.com>2016-03-03 17:39:17 -0800
committeralisdair sullivan <alisdair.sullivan@askuity.com>2016-03-03 17:39:17 -0800
commit0bd5e230d2689831cad1427287f3ecc62482dc1e (patch)
tree4dc24ffa4d7e9e35011cb816a5923120758d8602 /test
parentd75fa758d86fa062164671e0154ed1b05691b0f9 (diff)
move definition of 'EUNIT' macro to eunit provider
add definition of 'COMMON_TEST' macro to eunit provider
Diffstat (limited to 'test')
-rw-r--r--test/rebar_ct_SUITE.erl32
-rw-r--r--test/rebar_eunit_SUITE.erl43
2 files changed, 65 insertions, 10 deletions
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index 0e0de2e..1da7571 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -6,8 +6,10 @@
end_per_group/2]).
-export([basic_app_default_dirs/1,
basic_app_default_beams/1,
+ basic_app_ct_macro/1,
multi_app_default_dirs/1,
multi_app_default_beams/1,
+ multi_app_ct_macro/1,
single_app_dir/1,
single_extra_dir/1,
single_unmanaged_dir/1,
@@ -65,9 +67,11 @@ all() -> [{group, basic_app},
misspecified_ct_first_files].
groups() -> [{basic_app, [], [basic_app_default_dirs,
- basic_app_default_beams]},
+ basic_app_default_beams,
+ basic_app_ct_macro]},
{multi_app, [], [multi_app_default_dirs,
- multi_app_default_beams]},
+ multi_app_default_beams,
+ multi_app_ct_macro]},
{dirs_and_suites, [], [single_app_dir,
single_extra_dir,
single_unmanaged_dir,
@@ -121,7 +125,7 @@ init_per_group(basic_app, Config) ->
{ok, T} = Tests,
Opts = rebar_prv_common_test:translate_paths(NewState, T),
- [{result, Opts}, {appnames, [Name]}|C];
+ [{result, Opts}, {appnames, [Name]}, {compile_state, NewState}|C];
init_per_group(multi_app, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -156,7 +160,7 @@ init_per_group(multi_app, Config) ->
{ok, T} = Tests,
Opts = rebar_prv_common_test:translate_paths(NewState, T),
- [{result, Opts}, {appnames, [Name1, Name2]}|C];
+ [{result, Opts}, {appnames, [Name1, Name2]}, {compile_state, NewState}|C];
init_per_group(dirs_and_suites, Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_"),
@@ -255,6 +259,15 @@ basic_app_default_beams(Config) ->
true = filelib:is_file(File).
+basic_app_ct_macro(Config) ->
+ State = ?config(compile_state, Config),
+
+ [App] = rebar_state:project_apps(State),
+ Opts = rebar_app_info:opts(App),
+ ErlOpts = dict:fetch(erl_opts, Opts),
+ true = lists:member({d, 'COMMON_TEST'}, ErlOpts).
+
+
multi_app_default_dirs(Config) ->
AppDir = ?config(apps, Config),
[Name1, Name2] = ?config(appnames, Config),
@@ -296,6 +309,16 @@ multi_app_default_beams(Config) ->
true = filelib:is_file(File2),
true = filelib:is_file(File3).
+multi_app_ct_macro(Config) ->
+ State = ?config(compile_state, Config),
+
+ Apps = rebar_state:project_apps(State),
+ lists:foreach(fun(App) ->
+ Opts = rebar_app_info:opts(App),
+ ErlOpts = dict:fetch(erl_opts, Opts),
+ true = lists:member({d, 'COMMON_TEST'}, ErlOpts)
+ end, Apps).
+
single_app_dir(Config) ->
AppDir = ?config(apps, Config),
[Name1, _Name2] = ?config(appnames, Config),
@@ -1158,6 +1181,7 @@ misspecified_ct_first_files(Config) ->
{badconfig, {"Value `~p' of option `~p' must be a list", {some_file, ct_first_files}}} = Error.
+
%% helper for generating test data
test_suite(Name) ->
io_lib:format("-module(~ts_SUITE).\n"
diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl
index cb2c911..41ab6ff 100644
--- a/test/rebar_eunit_SUITE.erl
+++ b/test/rebar_eunit_SUITE.erl
@@ -2,8 +2,12 @@
-export([all/0, groups/0]).
-export([init_per_suite/1, init_per_group/2, end_per_group/2]).
--export([basic_app_compiles/1, basic_app_files/1, basic_app_exports/1, basic_app_testset/1]).
--export([multi_app_compiles/1, multi_app_files/1, multi_app_exports/1, multi_app_testset/1]).
+-export([basic_app_compiles/1, basic_app_files/1]).
+-export([basic_app_exports/1, basic_app_testset/1]).
+-export([basic_app_eunit_macro/1]).
+-export([multi_app_compiles/1, multi_app_files/1]).
+-export([multi_app_exports/1, multi_app_testset/1]).
+-export([multi_app_eunit_macro/1]).
-export([eunit_tests/1, eunit_opts/1, eunit_first_files/1]).
-export([single_application_arg/1, multi_application_arg/1, missing_application_arg/1]).
-export([single_module_arg/1, multi_module_arg/1, missing_module_arg/1]).
@@ -27,9 +31,15 @@ all() ->
groups() ->
[{basic_app, [sequence], [basic_app_compiles, {group, basic_app_results}]},
- {basic_app_results, [], [basic_app_files, basic_app_exports, basic_app_testset]},
+ {basic_app_results, [], [basic_app_files,
+ basic_app_exports,
+ basic_app_testset,
+ basic_app_eunit_macro]},
{multi_app, [sequence], [multi_app_compiles, {group, multi_app_results}]},
- {multi_app_results, [], [multi_app_files, multi_app_exports, multi_app_testset]},
+ {multi_app_results, [], [multi_app_files,
+ multi_app_exports,
+ multi_app_testset,
+ multi_app_eunit_macro]},
{cmd_line_args, [], [eunit_tests, eunit_opts, eunit_first_files,
single_application_arg, multi_application_arg, missing_application_arg,
single_module_arg, multi_module_arg, missing_module_arg,
@@ -160,7 +170,16 @@ basic_app_testset(Config) ->
{module, basic_app_tests_helper}]},
Set = rebar_prv_eunit:prepare_tests(Result).
-
+basic_app_eunit_macro(_Config) ->
+ Macro = fun(Mod) ->
+ begin
+ Path = code:which(Mod),
+ {ok, {Mod, [{compile_info, CompileInfo}]}} = beam_lib:chunks(Path, [compile_info]),
+ Opts = proplists:get_value(options, CompileInfo, []),
+ true = lists:member({d, 'EUNIT'}, Opts)
+ end
+ end,
+ lists:foreach(Macro, [basic_app, basic_app_tests, basic_app_tests_helper]).
%% === tests for multiple applications in the `apps' directory of a project ===
@@ -220,7 +239,19 @@ multi_app_testset(Config) ->
{module, multi_app_tests_helper}]},
Set = rebar_prv_eunit:prepare_tests(Result).
-
+multi_app_eunit_macro(_Config) ->
+ Macro = fun(Mod) ->
+ begin
+ Path = code:which(Mod),
+ {ok, {Mod, [{compile_info, CompileInfo}]}} = beam_lib:chunks(Path, [compile_info]),
+ Opts = proplists:get_value(options, CompileInfo, []),
+ true = lists:member({d, 'EUNIT'}, Opts)
+ end
+ end,
+ lists:foreach(Macro, [multi_app_bar, multi_app_bar_tests,
+ multi_app_baz, multi_app_baz_tests,
+ multi_app_tests, multi_app_tests_helper,
+ multi_app_bar_tests_helper, multi_app_baz_tests_helper]).
%% === tests for command line arguments ===