浏览代码

Revert "define the 'EUNIT' macro in the test profile"

This reverts commit 4c32c52b55.
pull/1108/head
alisdair sullivan 9 年前
父节点
当前提交
d75fa758d8
共有 2 个文件被更改,包括 14 次插入21 次删除
  1. +10
    -11
      src/rebar3.erl
  2. +4
    -10
      test/rebar_profiles_SUITE.erl

+ 10
- 11
src/rebar3.erl 查看文件

@ -337,19 +337,18 @@ state_from_global_config(Config, GlobalConfigFile) ->
test_state(State) ->
ErlOpts = rebar_state:get(State, erl_opts, []),
TestOpts = safe_define_test_macro(ErlOpts, 'TEST'),
MoreTestOpts = safe_define_test_macro(ErlOpts, 'EUNIT'),
[{extra_src_dirs, ["test"]}, {erl_opts, TestOpts ++ MoreTestOpts}].
TestOpts = safe_define_test_macro(ErlOpts),
[{extra_src_dirs, ["test"]}, {erl_opts, TestOpts}].
safe_define_test_macro(Opts, Macro) ->
safe_define_test_macro(Opts) ->
%% defining a compile macro twice results in an exception so
%% make sure 'TEST' or 'EUNIT' is only defined once
case test_defined(Opts, Macro) of
%% make sure 'TEST' is only defined once
case test_defined(Opts) of
true -> [];
false -> [{d, Macro}]
false -> [{d, 'TEST'}]
end.
test_defined([{d, Macro}|_], Macro) -> true;
test_defined([{d, Macro, true}|_], Macro) -> true;
test_defined([_|Rest], Macro) -> test_defined(Rest, Macro);
test_defined([], _) -> false.
test_defined([{d, 'TEST'}|_]) -> true;
test_defined([{d, 'TEST', true}|_]) -> true;
test_defined([_|Rest]) -> test_defined(Rest);
test_defined([]) -> false.

+ 4
- 10
test/rebar_profiles_SUITE.erl 查看文件

@ -377,8 +377,7 @@ test_profile_applied_at_completion(Config) ->
[App] = rebar_state:project_apps(State),
ErlOpts = rebar_app_info:get(App, erl_opts),
true = lists:member({d, 'TEST'}, ErlOpts),
true = lists:member({d, 'EUNIT'}, ErlOpts).
true = lists:member({d, 'TEST'}, ErlOpts).
test_profile_applied_before_compile(Config) ->
AppDir = ?config(apps, Config),
@ -394,9 +393,7 @@ test_profile_applied_before_compile(Config) ->
code:add_paths(rebar_state:code_paths(State, all_deps)),
S = list_to_atom("not_a_real_src_" ++ Name),
Opts = proplists:get_value(options, S:module_info(compile), []),
true = lists:member({d, 'TEST'}, Opts),
true = lists:member({d, 'EUNIT'}, Opts).
true = lists:member({d, 'TEST'}, proplists:get_value(options, S:module_info(compile), [])).
test_profile_applied_before_eunit(Config) ->
AppDir = ?config(apps, Config),
@ -412,9 +409,7 @@ test_profile_applied_before_eunit(Config) ->
code:add_paths(rebar_state:code_paths(State, all_deps)),
T = list_to_atom("not_a_real_src_" ++ Name ++ "_tests"),
Opts = proplists:get_value(options, T:module_info(compile), []),
true = lists:member({d, 'TEST'}, Opts),
true = lists:member({d, 'EUNIT'}, Opts).
true = lists:member({d, 'TEST'}, proplists:get_value(options, T:module_info(compile), [])).
test_profile_applied_to_apps(Config) ->
AppDir = ?config(apps, Config),
@ -435,6 +430,5 @@ test_profile_applied_to_apps(Config) ->
lists:foreach(fun(App) ->
Opts = rebar_app_info:opts(App),
ErlOpts = dict:fetch(erl_opts, Opts),
true = lists:member({d, 'TEST'}, ErlOpts),
true = lists:member({d, 'EUNIT'}, ErlOpts)
true = lists:member({d, 'TEST'}, ErlOpts)
end, Apps).

正在加载...
取消
保存