From ed45ed2d8a7329a9749d98ac5455d853047ab9e0 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Thu, 5 Mar 2015 20:24:08 -0800 Subject: two failing tests and one passing test to attempt to isolate where profiles are failing to be applied relevant to #224 and #233 --- test/rebar_profiles_SUITE.erl | 50 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 8a1521e..8f87832 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -10,7 +10,10 @@ profile_merges/1, add_to_profile/1, add_to_existing_profile/1, - profiles_remain_applied_with_config_present/1]). + profiles_remain_applied_with_config_present/1, + test_profile_applied_at_completion/1, + test_profile_applied_before_compile/1, + test_profile_applied_before_eunit/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -19,7 +22,10 @@ all() -> [profile_new_key, profile_merge_keys, profile_merges, add_to_profile, add_to_existing_profile, - profiles_remain_applied_with_config_present]. + profiles_remain_applied_with_config_present, + test_profile_applied_at_completion, + test_profile_applied_before_compile, + test_profile_applied_before_eunit]. init_per_suite(Config) -> application:start(meck), @@ -151,3 +157,43 @@ profiles_remain_applied_with_config_present(Config) -> Mod = list_to_atom("not_a_real_src_" ++ Name), true = lists:member({d, not_ok}, proplists:get_value(options, Mod:module_info(compile), [])). + +test_profile_applied_at_completion(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("test_profile_at_completion_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + {ok, State} = rebar_test_utils:run_and_check(Config, + [], + ["eunit"], + return), + + Opts = rebar_state:opts(State), + ErlOpts = dict:fetch(erl_opts, Opts), + true = lists:member({d, 'TEST'}, ErlOpts). + +test_profile_applied_before_compile(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("test_profile_before_compile_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}), + + S = list_to_atom("not_a_real_src_" ++ Name), + true = lists:member({d, 'TEST'}, proplists:get_value(options, S:module_info(compile), [])). + +test_profile_applied_before_eunit(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("test_profile_before_eunit_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}), + + T = list_to_atom("not_a_real_src_" ++ Name ++ "_tests"), + true = lists:member({d, 'TEST'}, proplists:get_value(options, T:module_info(compile), [])). -- cgit v1.1 From 67aca881c1ad5f3bb3f10c28bc0bc04c45d09407 Mon Sep 17 00:00:00 2001 From: alisdair sullivan Date: Thu, 5 Mar 2015 20:40:06 -0800 Subject: add test for test profile applied to project apps --- test/rebar_profiles_SUITE.erl | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'test') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 8f87832..55ab3d7 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -13,7 +13,8 @@ profiles_remain_applied_with_config_present/1, test_profile_applied_at_completion/1, test_profile_applied_before_compile/1, - test_profile_applied_before_eunit/1]). + test_profile_applied_before_eunit/1, + test_profile_applied_to_apps/1]). -include_lib("common_test/include/ct.hrl"). -include_lib("eunit/include/eunit.hrl"). @@ -25,7 +26,8 @@ all() -> profiles_remain_applied_with_config_present, test_profile_applied_at_completion, test_profile_applied_before_compile, - test_profile_applied_before_eunit]. + test_profile_applied_before_eunit, + test_profile_applied_to_apps]. init_per_suite(Config) -> application:start(meck), @@ -197,3 +199,23 @@ test_profile_applied_before_eunit(Config) -> T = list_to_atom("not_a_real_src_" ++ Name ++ "_tests"), true = lists:member({d, 'TEST'}, proplists:get_value(options, T:module_info(compile), [])). + +test_profile_applied_to_apps(Config) -> + AppDir = ?config(apps, Config), + + Name = rebar_test_utils:create_random_name("test_profile_applied_to_apps_"), + Vsn = rebar_test_utils:create_random_vsn(), + rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + + {ok, State} = rebar_test_utils:run_and_check(Config, + [], + ["eunit"], + return), + + Apps = rebar_state:project_apps(State), + lists:foreach(fun(App) -> + AppState = rebar_app_info:state(App), + Opts = rebar_state:opts(AppState), + ErlOpts = dict:fetch(erl_opts, Opts), + true = lists:member({d, 'TEST'}, ErlOpts) + end, Apps). -- cgit v1.1 From 0638c85634f3f9f51f17f247a3376f72b2f4d2fa Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 6 Mar 2015 08:59:10 -0600 Subject: store base opts after initialization of providers --- test/rebar_profiles_SUITE.erl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'test') diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl index 55ab3d7..a4f926e 100644 --- a/test/rebar_profiles_SUITE.erl +++ b/test/rebar_profiles_SUITE.erl @@ -167,8 +167,11 @@ test_profile_applied_at_completion(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + RebarConfig = [{erl_opts, [{d, some_define}]}], + rebar_test_utils:create_config(AppDir, RebarConfig), + {ok, State} = rebar_test_utils:run_and_check(Config, - [], + RebarConfig, ["eunit"], return), @@ -183,7 +186,10 @@ test_profile_applied_before_compile(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), - rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}), + RebarConfig = [{erl_opts, [{d, some_define}]}], + rebar_test_utils:create_config(AppDir, RebarConfig), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["eunit"], {ok, [{app, Name}]}), S = list_to_atom("not_a_real_src_" ++ Name), true = lists:member({d, 'TEST'}, proplists:get_value(options, S:module_info(compile), [])). @@ -195,7 +201,10 @@ test_profile_applied_before_eunit(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), - rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}), + RebarConfig = [{erl_opts, [{d, some_define}]}], + rebar_test_utils:create_config(AppDir, RebarConfig), + + rebar_test_utils:run_and_check(Config, RebarConfig, ["eunit"], {ok, [{app, Name}]}), T = list_to_atom("not_a_real_src_" ++ Name ++ "_tests"), true = lists:member({d, 'TEST'}, proplists:get_value(options, T:module_info(compile), [])). @@ -207,8 +216,11 @@ test_profile_applied_to_apps(Config) -> Vsn = rebar_test_utils:create_random_vsn(), rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]), + RebarConfig = [{erl_opts, [{d, some_define}]}], + rebar_test_utils:create_config(AppDir, RebarConfig), + {ok, State} = rebar_test_utils:run_and_check(Config, - [], + RebarConfig, ["eunit"], return), -- cgit v1.1