diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/rebar_eunit_SUITE.erl | 79 | ||||
-rw-r--r-- | test/rebar_profiles_SUITE.erl | 4 |
2 files changed, 78 insertions, 5 deletions
diff --git a/test/rebar_eunit_SUITE.erl b/test/rebar_eunit_SUITE.erl index 69ffaf5..6b2bb0f 100644 --- a/test/rebar_eunit_SUITE.erl +++ b/test/rebar_eunit_SUITE.erl @@ -23,7 +23,9 @@ test_multiple_dir_flag/1, test_nonexistent_dir_flag/1, test_config_tests/1, - test_nonexistent_tests/1]). + test_nonexistent_tests/1, + eunit_compile_opts/1, + eunit_first_files/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -49,7 +51,8 @@ all() -> test_single_module_flag, test_nonexistent_module_flag, test_single_file_flag, test_multiple_file_flag, test_nonexistent_file_flag, test_single_dir_flag, test_multiple_dir_flag, test_nonexistent_dir_flag, - test_config_tests, test_nonexistent_tests]. + test_config_tests, test_nonexistent_tests, + eunit_compile_opts, eunit_first_files]. test_basic_app(Config) -> AppDir = ?config(apps, Config), @@ -522,4 +525,74 @@ test_nonexistent_tests(Config) -> "Directory `not_a_real_dir' not found.", "File `not_a_real_file.beam' not found.", "Module `not_a_real_module' not found in applications.", - "Module `not_a_real_suite' not found in applications."]}.
\ No newline at end of file + "Module `not_a_real_suite' not found in applications."]}. + +eunit_compile_opts(Config) -> + AppDir = ?config(apps, Config), + + Name1 = rebar_test_utils:create_random_name("multi_app1_"), + Vsn1 = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]), + Name1, + Vsn1, + [kernel, stdlib]), + Name2 = rebar_test_utils:create_random_name("multi_app2_"), + Vsn2 = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]), + Name2, + Vsn2, + [kernel, stdlib]), + + RebarConfig = [{erl_opts, [{d, some_define}]}, {eunit_compile_opts, [{d, some_other_define}]}], + rebar_test_utils:run_and_check(Config, + RebarConfig, + ["eunit"], + {ok, [{app, Name1}, {app, Name2}]}), + + App1 = list_to_atom("not_a_real_src_" ++ Name1), + Suite1 = list_to_atom("not_a_real_src_" ++ Name1 ++ "_tests"), + AppOpts1 = proplists:get_value(options, App1:module_info(compile), []), + SuiteOpts1 = proplists:get_value(options, Suite1:module_info(compile), []), + + App2 = list_to_atom("not_a_real_src_" ++ Name2), + Suite2 = list_to_atom("not_a_real_src_" ++ Name2 ++ "_tests"), + AppOpts2 = proplists:get_value(options, App2:module_info(compile), []), + SuiteOpts2 = proplists:get_value(options, Suite2:module_info(compile), []), + + Expect = [{d, some_other_define}, {d, some_define}], + lists:foreach(fun(E) -> true = lists:member(E, AppOpts1) end, Expect), + lists:foreach(fun(E) -> true = lists:member(E, SuiteOpts1) end, Expect), + lists:foreach(fun(E) -> true = lists:member(E, AppOpts2) end, Expect), + lists:foreach(fun(E) -> true = lists:member(E, SuiteOpts2) end, Expect). + +eunit_first_files(Config) -> + AppDir = ?config(apps, Config), + + Name1 = rebar_test_utils:create_random_name("multi_app1_"), + Vsn1 = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name1]), + Name1, + Vsn1, + [kernel, stdlib]), + Name2 = rebar_test_utils:create_random_name("multi_app2_"), + Vsn2 = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_eunit_app(filename:join([AppDir,"apps",Name2]), + Name2, + Vsn2, + [kernel, stdlib]), + + ErlFirstFiles = ["not_a_real_src_" ++ Name1, "not_a_real_src_" ++ Name2], + EUnitFirstFiles = ["not_a_real_src_" ++ Name1 ++ "_tests", "not_a_real_src_" ++ Name2 ++ "_tests"], + + RebarConfig = [{erl_opts, [{d, some_define}]}, + {erl_first_files, ErlFirstFiles}, + {eunit_first_files, EUnitFirstFiles}], + {ok, State} = rebar_test_utils:run_and_check(Config, + RebarConfig, + ["eunit"], + {ok, [{app, Name1}, {app, Name2}]}), + + AllFirstFiles = EUnitFirstFiles ++ ErlFirstFiles, + Apps = rebar_state:project_apps(State), + lists:foreach(fun(App) -> AllFirstFiles = rebar_app_info:get(App, erl_first_files) end, + Apps).
\ No newline at end of file diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index d4c10c5..a31a4c9 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -375,8 +375,8 @@ test_profile_applied_at_completion(Config) -> ["eunit"], return), - Opts = rebar_state:opts(State), - ErlOpts = dict:fetch(erl_opts, Opts), + [App] = rebar_state:project_apps(State), + ErlOpts = rebar_app_info:get(App, erl_opts), true = lists:member({d, 'TEST'}, ErlOpts). test_profile_applied_before_compile(Config) -> |