mirror of
https://github.com/correl/rebar.git
synced 2024-12-18 03:00:17 +00:00
Add PropEr support
This commit is contained in:
parent
c6da0b3ef6
commit
377c9e86d5
1 changed files with 24 additions and 17 deletions
|
@ -177,33 +177,40 @@ get_eunit_opts(Config) ->
|
||||||
BaseOpts ++ rebar_config:get_list(Config, eunit_opts, []).
|
BaseOpts ++ rebar_config:get_list(Config, eunit_opts, []).
|
||||||
|
|
||||||
eunit_config(Config) ->
|
eunit_config(Config) ->
|
||||||
EqcOpts = case is_quickcheck_avail() of
|
EqcOpts = eqc_opts(),
|
||||||
true ->
|
PropErOpts = proper_opts(),
|
||||||
[{d, 'EQC'}];
|
|
||||||
false ->
|
|
||||||
[]
|
|
||||||
end,
|
|
||||||
|
|
||||||
ErlOpts = rebar_config:get_list(Config, erl_opts, []),
|
ErlOpts = rebar_config:get_list(Config, erl_opts, []),
|
||||||
EunitOpts = rebar_config:get_list(Config, eunit_compile_opts, []),
|
EunitOpts = rebar_config:get_list(Config, eunit_compile_opts, []),
|
||||||
Opts = [{d, 'TEST'}, debug_info] ++
|
Opts = [{d, 'TEST'}, debug_info] ++
|
||||||
ErlOpts ++ EunitOpts ++ EqcOpts,
|
ErlOpts ++ EunitOpts ++ EqcOpts ++ PropErOpts,
|
||||||
Config1 = rebar_config:set(Config, erl_opts, Opts),
|
Config1 = rebar_config:set(Config, erl_opts, Opts),
|
||||||
|
|
||||||
FirstErls = rebar_config:get_list(Config1, eunit_first_files, []),
|
FirstErls = rebar_config:get_list(Config1, eunit_first_files, []),
|
||||||
rebar_config:set(Config1, erl_first_files, FirstErls).
|
rebar_config:set(Config1, erl_first_files, FirstErls).
|
||||||
|
|
||||||
is_quickcheck_avail() ->
|
|
||||||
case erlang:get(is_quickcheck_avail) of
|
eqc_opts() ->
|
||||||
|
define_if('PROPER', is_lib_avail(is_eqc_avail, eqc,
|
||||||
|
"eqc.hrl", "QuickCheck")).
|
||||||
|
proper_opts() ->
|
||||||
|
define_if('EQC', is_lib_avail(is_proper_avail, proper,
|
||||||
|
"proper.hrl", "PropEr")).
|
||||||
|
|
||||||
|
define_if(Def, true) -> [{d, Def}];
|
||||||
|
define_if(_Def, false) -> [].
|
||||||
|
|
||||||
|
is_lib_avail(DictKey, Mod, Hrl, Name) ->
|
||||||
|
case erlang:get(DictKey) of
|
||||||
undefined ->
|
undefined ->
|
||||||
case code:lib_dir(eqc, include) of
|
IsAvail = case code:lib_dir(Mod, include) of
|
||||||
{error, bad_name} ->
|
{error, bad_name} ->
|
||||||
IsAvail = false;
|
false;
|
||||||
Dir ->
|
Dir ->
|
||||||
IsAvail = filelib:is_regular(filename:join(Dir, "eqc.hrl"))
|
filelib:is_regular(filename:join(Dir, Hrl))
|
||||||
end,
|
end,
|
||||||
erlang:put(is_quickcheck_avail, IsAvail),
|
erlang:put(DictKey, IsAvail),
|
||||||
?DEBUG("Quickcheck availability: ~p\n", [IsAvail]),
|
?DEBUG("~s availability: ~p\n", [Name, IsAvail]),
|
||||||
IsAvail;
|
IsAvail;
|
||||||
IsAvail ->
|
IsAvail ->
|
||||||
IsAvail
|
IsAvail
|
||||||
|
|
Loading…
Reference in a new issue