summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/rebar_ct_SUITE.erl78
-rw-r--r--test/rebar_eunit_SUITE.erl65
2 files changed, 132 insertions, 11 deletions
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index c4fc4dc..267a9ee 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -38,9 +38,12 @@
cmd_create_priv_dir/1,
cfg_opts/1,
cfg_arbitrary_opts/1,
- cfg_test_spec_filtered/1,
+ cfg_test_spec/1,
cfg_atom_suites/1,
- cover_compiled/1]).
+ cover_compiled/1,
+ misspecified_ct_opts/1,
+ misspecified_ct_compile_opts/1,
+ misspecified_ct_first_files/1]).
-include_lib("common_test/include/ct.hrl").
@@ -51,8 +54,11 @@ all() -> [{group, basic_app},
{group, ct_opts},
{group, cover},
cfg_opts, cfg_arbitrary_opts,
- cfg_test_spec_filtered,
- cfg_atom_suites].
+ cfg_test_spec,
+ cfg_atom_suites,
+ misspecified_ct_opts,
+ misspecified_ct_compile_opts,
+ misspecified_ct_first_files].
groups() -> [{basic_app, [], [basic_app_default_dirs,
basic_app_default_beams]},
@@ -911,12 +917,12 @@ cfg_arbitrary_opts(Config) ->
true = lists:member({bar, 2}, TestOpts),
true = lists:member({baz, 3}, TestOpts).
-cfg_test_spec_filtered(Config) ->
- C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_test_spec_filtered_opts_"),
+cfg_test_spec(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_test_spec_opts_"),
AppDir = ?config(apps, C),
- Name = rebar_test_utils:create_random_name("ct_cfg_test_spec_filtered_opts_"),
+ Name = rebar_test_utils:create_random_name("ct_cfg_test_spec_opts_"),
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
@@ -924,9 +930,9 @@ cfg_test_spec_filtered(Config) ->
{ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
- {ok, TestOpts} = rebar_prv_common_test:prepare_tests(State),
+ {error, {rebar_prv_common_test, Error}} = rebar_prv_common_test:prepare_tests(State),
- false = lists:keysearch(test_spec, 1, TestOpts).
+ {badconfig, "Test specs not supported"} = Error.
cfg_atom_suites(Config) ->
C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
@@ -962,7 +968,59 @@ cover_compiled(Config) ->
Name = ?config(name, Config),
Mod = list_to_atom(Name),
{file, _} = cover:is_compiled(Mod).
-
+
+misspecified_ct_opts(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_atom_suites_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_opts, {basic_html, false}}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ {error, {rebar_prv_common_test, Error}} = rebar_prv_common_test:prepare_tests(State),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {{basic_html, false}, ct_opts}}} = Error.
+
+misspecified_ct_compile_opts(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_atom_suites_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_compile_opts, {d, whatever}}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ Tests = rebar_prv_common_test:prepare_tests(State),
+ {error, {rebar_prv_common_test, Error}} = rebar_prv_common_test:compile(State, Tests),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {{d, whatever}, ct_compile_opts}}} = Error.
+
+misspecified_ct_first_files(Config) ->
+ C = rebar_test_utils:init_rebar_state(Config, "ct_cfg_atom_suites_"),
+
+ AppDir = ?config(apps, C),
+
+ Name = rebar_test_utils:create_random_name("ct_cfg_atom_suites_"),
+ Vsn = rebar_test_utils:create_random_vsn(),
+ rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+
+ RebarConfig = [{ct_first_files, some_file}],
+
+ {ok, State} = rebar_test_utils:run_and_check(C, RebarConfig, ["as", "test", "lock"], return),
+
+ Tests = rebar_prv_common_test:prepare_tests(State),
+ {error, {rebar_prv_common_test, Error}} = rebar_prv_common_test:compile(State, Tests),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {some_file, ct_first_files}}} = Error.
%% helper for generating test data
test_suite(Name) ->
diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl
index 262eb92..1b11c5a 100644
--- a/test/rebar_eunit_SUITE.erl
+++ b/test/rebar_eunit_SUITE.erl
@@ -11,13 +11,19 @@
-export([single_file_arg/1, multi_file_arg/1, missing_file_arg/1]).
-export([single_dir_arg/1, multi_dir_arg/1, missing_dir_arg/1]).
-export([multiple_arg_composition/1, multiple_arg_errors/1]).
+-export([misspecified_eunit_tests/1]).
+-export([misspecified_eunit_compile_opts/1]).
+-export([misspecified_eunit_first_files/1]).
-include_lib("common_test/include/ct.hrl").
-include_lib("eunit/include/eunit.hrl").
-include_lib("kernel/include/file.hrl").
all() ->
- [{group, basic_app}, {group, multi_app}, {group, cmd_line_args}].
+ [{group, basic_app}, {group, multi_app}, {group, cmd_line_args},
+ misspecified_eunit_tests,
+ misspecified_eunit_compile_opts,
+ misspecified_eunit_first_files].
groups() ->
[{basic_app, [sequence], [basic_app_compiles, {group, basic_app_results}]},
@@ -484,3 +490,60 @@ multiple_arg_errors(Config) ->
{error, {rebar_prv_eunit, {eunit_test_errors, Expect}}} = Tests.
+misspecified_eunit_tests(Config) ->
+ State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
+
+ AppDir = ?config(apps, State),
+ PrivDir = ?config(priv_dir, State),
+
+ AppDirs = ["src", "include", "test"],
+
+ lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
+ filename:join([AppDir, F]),
+ [recursive]) end, AppDirs),
+
+ BaseConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
+
+ RebarConfig = [{eunit_tests, {dir, "test"}}|BaseConfig],
+
+ {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {{dir, "test"}, eunit_tests}}} = Error.
+
+misspecified_eunit_compile_opts(Config) ->
+ State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
+
+ AppDir = ?config(apps, State),
+ PrivDir = ?config(priv_dir, State),
+
+ AppDirs = ["src", "include", "test"],
+
+ lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
+ filename:join([AppDir, F]),
+ [recursive]) end, AppDirs),
+
+ RebarConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, {d, eunit_compile_define}}],
+
+ {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {{d, eunit_compile_define}, eunit_compile_opts}}} = Error.
+
+misspecified_eunit_first_files(Config) ->
+ State = rebar_test_utils:init_rebar_state(Config, "basic_app_"),
+
+ AppDir = ?config(apps, State),
+ PrivDir = ?config(priv_dir, State),
+
+ AppDirs = ["src", "include", "test"],
+
+ lists:foreach(fun(F) -> ec_file:copy(filename:join([PrivDir, "basic_app", F]),
+ filename:join([AppDir, F]),
+ [recursive]) end, AppDirs),
+
+ BaseConfig = [{erl_opts, [{d, config_define}]}, {eunit_compile_opts, [{d, eunit_compile_define}]}],
+
+ RebarConfig = [{eunit_first_files, some_file}|BaseConfig],
+
+ {error, {rebar_prv_eunit, Error}} = rebar_test_utils:run_and_check(State, RebarConfig, ["eunit"], return),
+
+ {badconfig, {"Value `~p' of option `~p' must be a list", {some_file, eunit_first_files}}} = Error. \ No newline at end of file