From 17e26f72653706e8c555082a2c9ae9e73351fff8 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Fri, 30 Oct 2015 01:01:12 -0700 Subject: delay validation of eunit tests until just before running --- test/rebar_eunit_SUITE.erl | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) (limited to 'test/rebar_eunit_SUITE.erl') diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl index 609be51..262eb92 100644 --- a/test/rebar_eunit_SUITE.erl +++ b/test/rebar_eunit_SUITE.erl @@ -268,7 +268,7 @@ missing_application_arg(Config) -> State = rebar_state:command_parsed_args(S, Args), Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Application `missing_app' not found in project."]}}}, - Error = rebar_prv_eunit:prepare_tests(State). + Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)). %% check that the --module cmd line opt generates the correct test set single_module_arg(Config) -> @@ -311,8 +311,11 @@ missing_module_arg(Config) -> {ok, Args} = getopt:parse(rebar_prv_eunit:eunit_opts(S), ["--module=missing_app"]), State = rebar_state:command_parsed_args(S, Args), + T = rebar_prv_eunit:prepare_tests(State), + Tests = rebar_prv_eunit:validate_tests(S, T), + Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Module `missing_app' not found in project."]}}}, - Error = rebar_prv_eunit:prepare_tests(State). + Error = Tests. %% check that the --suite cmd line opt generates the correct test set single_suite_arg(Config) -> @@ -356,7 +359,7 @@ missing_suite_arg(Config) -> State = rebar_state:command_parsed_args(S, Args), Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Module `missing_app' not found in project."]}}}, - Error = rebar_prv_eunit:prepare_tests(State). + Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)). %% check that the --file cmd line opt generates the correct test set single_file_arg(Config) -> @@ -390,7 +393,7 @@ missing_file_arg(Config) -> State = rebar_state:command_parsed_args(S, Args), Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["File `" ++ Path ++"' not found."]}}}, - Error = rebar_prv_eunit:prepare_tests(State). + Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)). %% check that the --dir cmd line opt generates the correct test set single_dir_arg(Config) -> @@ -424,7 +427,7 @@ missing_dir_arg(Config) -> State = rebar_state:command_parsed_args(S, Args), Error = {error, {rebar_prv_eunit, {eunit_test_errors, ["Directory `" ++ Path ++"' not found."]}}}, - Error = rebar_prv_eunit:prepare_tests(State). + Error = rebar_prv_eunit:validate_tests(State, rebar_prv_eunit:prepare_tests(State)). %% check that multiple args are composed multiple_arg_composition(Config) -> @@ -470,11 +473,14 @@ multiple_arg_errors(Config) -> "--dir=" ++ DirPath]), State = rebar_state:command_parsed_args(S, Args), + T = rebar_prv_eunit:prepare_tests(State), + Tests = rebar_prv_eunit:validate_tests(S, T), + Expect = ["Application `missing_app' not found in project.", "Directory `" ++ DirPath ++ "' not found.", "File `" ++ FilePath ++ "' not found.", "Module `missing_app' not found in project.", "Module `missing_app' not found in project."], - {error, {rebar_prv_eunit, {eunit_test_errors, Expect}}} = rebar_prv_eunit:prepare_tests(State). + {error, {rebar_prv_eunit, {eunit_test_errors, Expect}}} = Tests. -- cgit v1.1 From 25914c35086beca01aaf879c5227adba7dfe1037 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sun, 15 Nov 2015 15:52:19 -0800 Subject: error on ct/eunit argument errors instead of warning --- test/rebar_eunit_SUITE.erl | 65 +++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) (limited to 'test/rebar_eunit_SUITE.erl') 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 -- cgit v1.1 From 6ba96dcf4563b2d1c4433425a182ac086643ed01 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Thu, 7 Jan 2016 15:38:56 -0500 Subject: Avoid changing directories in test suite --- test/rebar_eunit_SUITE.erl | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'test/rebar_eunit_SUITE.erl') diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl index 1b11c5a..896c624 100644 --- a/test/rebar_eunit_SUITE.erl +++ b/test/rebar_eunit_SUITE.erl @@ -42,13 +42,10 @@ groups() -> init_per_suite(Config) -> PrivDir = ?config(priv_dir, Config), DataDir = ?config(data_dir, Config), - {ok, Cwd} = file:get_cwd(), - file:set_cwd(PrivDir), ok = ec_file:copy(filename:join([DataDir, "basic_app.zip"]), filename:join([PrivDir, "basic_app.zip"])), - {ok, _} = zip:extract(filename:join([PrivDir, "basic_app.zip"])), + {ok, _} = zip:extract(filename:join([PrivDir, "basic_app.zip"]), [{cwd, PrivDir}]), ok = ec_file:copy(filename:join([DataDir, "multi_app.zip"]), filename:join([PrivDir, "multi_app.zip"])), - {ok, _} = zip:extract(filename:join([PrivDir, "multi_app.zip"])), - file:set_cwd(Cwd), + {ok, _} = zip:extract(filename:join([PrivDir, "multi_app.zip"]), [{cwd, PrivDir}]), Config. init_per_group(basic_app, Config) -> @@ -546,4 +543,4 @@ misspecified_eunit_first_files(Config) -> {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 + {badconfig, {"Value `~p' of option `~p' must be a list", {some_file, eunit_first_files}}} = Error. -- cgit v1.1 From a8dc8ce6e682481aa8178f5cac0ad711e432eaed Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Sun, 17 Jan 2016 14:49:39 -0800 Subject: deduplicate default test set generated by `rebar3 eunit` this ONLY attempts to deduplicate test sets that are generated by rebar in the absence of any user specified tests --- test/rebar_eunit_SUITE.erl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'test/rebar_eunit_SUITE.erl') diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl index 896c624..cb2c911 100644 --- a/test/rebar_eunit_SUITE.erl +++ b/test/rebar_eunit_SUITE.erl @@ -156,7 +156,9 @@ basic_app_exports(_Config) -> basic_app_testset(Config) -> Result = ?config(result, Config), - {ok, [{application, basic_app}]} = rebar_prv_eunit:prepare_tests(Result). + Set = {ok, [{application, basic_app}, + {module, basic_app_tests_helper}]}, + Set = rebar_prv_eunit:prepare_tests(Result). @@ -208,12 +210,14 @@ multi_app_exports(_Config) -> %% check that the correct tests are schedule to run for project multi_app_testset(Config) -> - AppDir = ?config(apps, Config), Result = ?config(result, Config), - Set = {ok, [{application, multi_app_bar}, - {application, multi_app_baz}, - {dir, filename:join([AppDir, "test"])}]}, + Set = {ok, [{application, multi_app_baz}, + {application, multi_app_bar}, + {module, multi_app_bar_tests_helper}, + {module, multi_app_baz_tests_helper}, + {module, multi_app_tests}, + {module, multi_app_tests_helper}]}, Set = rebar_prv_eunit:prepare_tests(Result). -- cgit v1.1