mirror of
https://github.com/correl/rebar.git
synced 2024-11-27 11:09:55 +00:00
Separate eunit and qc compile options
This commit is contained in:
parent
803f6e8ecd
commit
99b645e4a3
4 changed files with 24 additions and 15 deletions
|
@ -22,13 +22,6 @@
|
||||||
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
|
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
|
||||||
{platform_define, "R13", 'old_inets'}]}.
|
{platform_define, "R13", 'old_inets'}]}.
|
||||||
|
|
||||||
%% Additional compile options for test-compile. erl_opts is also used
|
|
||||||
{test_compile_opts, []}.
|
|
||||||
|
|
||||||
%% Same as erl_first_files, but used only when running 'test-compile', 'eunit',
|
|
||||||
%% or 'qc'
|
|
||||||
{test_first_files, []}.
|
|
||||||
|
|
||||||
%% MIB Options?
|
%% MIB Options?
|
||||||
{mib_opts, []}.
|
{mib_opts, []}.
|
||||||
|
|
||||||
|
@ -72,6 +65,14 @@
|
||||||
%% Options for eunit:test()
|
%% Options for eunit:test()
|
||||||
{eunit_opts, []}.
|
{eunit_opts, []}.
|
||||||
|
|
||||||
|
%% Additional compile options for eunit. erl_opts is also used
|
||||||
|
{eunit_compile_opts, []}.
|
||||||
|
|
||||||
|
%% Same as erl_first_files, but used only when running 'eunit'
|
||||||
|
{eunit_first_files, []}.
|
||||||
|
|
||||||
|
%% == Cover ==
|
||||||
|
|
||||||
%% Whether to enable coverage reporting. Default is `false'
|
%% Whether to enable coverage reporting. Default is `false'
|
||||||
{cover_enabled, false}.
|
{cover_enabled, false}.
|
||||||
|
|
||||||
|
@ -100,6 +101,12 @@
|
||||||
%% If qc_mod is unspecified, rebar tries to detect Triq or EQC
|
%% If qc_mod is unspecified, rebar tries to detect Triq or EQC
|
||||||
{qc_opts, [{qc_mod, module()}, Options]}.
|
{qc_opts, [{qc_mod, module()}, Options]}.
|
||||||
|
|
||||||
|
%% Additional compile options for qc. erl_opts is also used
|
||||||
|
{qc_compile_opts, []}.
|
||||||
|
|
||||||
|
%% Same as erl_first_files, but used only when running 'qc'
|
||||||
|
{qc_first_files, []}.
|
||||||
|
|
||||||
%% == Cleanup ==
|
%% == Cleanup ==
|
||||||
|
|
||||||
%% Which files to cleanup
|
%% Which files to cleanup
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
clean/2]).
|
clean/2]).
|
||||||
|
|
||||||
%% for internal use by only eunit and qc
|
%% for internal use by only eunit and qc
|
||||||
-export([test_compile/1]).
|
-export([test_compile/2]).
|
||||||
|
|
||||||
-include("rebar.hrl").
|
-include("rebar.hrl").
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ clean(_Config, _AppFile) ->
|
||||||
%% .erl Compilation API (externally used by only eunit and qc)
|
%% .erl Compilation API (externally used by only eunit and qc)
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
test_compile(Config) ->
|
test_compile(Config, Cmd) ->
|
||||||
%% Obtain all the test modules for inclusion in the compile stage.
|
%% Obtain all the test modules for inclusion in the compile stage.
|
||||||
%% Notice: this could also be achieved with the following
|
%% Notice: this could also be achieved with the following
|
||||||
%% rebar.config option: {test_compile_opts, [{src_dirs, ["test"]}]}
|
%% rebar.config option: {test_compile_opts, [{src_dirs, ["test"]}]}
|
||||||
|
@ -157,7 +157,7 @@ test_compile(Config) ->
|
||||||
%% Compile erlang code to ?TEST_DIR, using a tweaked config
|
%% Compile erlang code to ?TEST_DIR, using a tweaked config
|
||||||
%% with appropriate defines for eunit, and include all the test modules
|
%% with appropriate defines for eunit, and include all the test modules
|
||||||
%% as well.
|
%% as well.
|
||||||
ok = doterl_compile(test_compile_config(Config), ?TEST_DIR, TestErls),
|
ok = doterl_compile(test_compile_config(Config, Cmd), ?TEST_DIR, TestErls),
|
||||||
|
|
||||||
{ok, SrcErls}.
|
{ok, SrcErls}.
|
||||||
|
|
||||||
|
@ -165,19 +165,21 @@ test_compile(Config) ->
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%% ===================================================================
|
%% ===================================================================
|
||||||
|
|
||||||
test_compile_config(Config) ->
|
test_compile_config(Config, Cmd) ->
|
||||||
{Config1, TriqOpts} = triq_opts(Config),
|
{Config1, TriqOpts} = triq_opts(Config),
|
||||||
{Config2, PropErOpts} = proper_opts(Config1),
|
{Config2, PropErOpts} = proper_opts(Config1),
|
||||||
{Config3, EqcOpts} = eqc_opts(Config2),
|
{Config3, EqcOpts} = eqc_opts(Config2),
|
||||||
|
|
||||||
ErlOpts = rebar_config:get_list(Config3, erl_opts, []),
|
ErlOpts = rebar_config:get_list(Config3, erl_opts, []),
|
||||||
EunitOpts = rebar_config:get_list(Config3, test_compile_opts, []),
|
OptsAtom = list_to_atom(Cmd ++ "_compile_opts"),
|
||||||
|
EunitOpts = rebar_config:get_list(Config3, OptsAtom, []),
|
||||||
Opts0 = [{d, 'TEST'}] ++
|
Opts0 = [{d, 'TEST'}] ++
|
||||||
ErlOpts ++ EunitOpts ++ TriqOpts ++ PropErOpts ++ EqcOpts,
|
ErlOpts ++ EunitOpts ++ TriqOpts ++ PropErOpts ++ EqcOpts,
|
||||||
Opts = [O || O <- Opts0, O =/= no_debug_info],
|
Opts = [O || O <- Opts0, O =/= no_debug_info],
|
||||||
Config4 = rebar_config:set(Config3, erl_opts, Opts),
|
Config4 = rebar_config:set(Config3, erl_opts, Opts),
|
||||||
|
|
||||||
FirstErls = rebar_config:get_list(Config4, test_first_files, []),
|
FirstFilesAtom = list_to_atom(Cmd ++ "_first_files"),
|
||||||
|
FirstErls = rebar_config:get_list(Config4, FirstFilesAtom, []),
|
||||||
rebar_config:set(Config4, erl_first_files, FirstErls).
|
rebar_config:set(Config4, erl_first_files, FirstErls).
|
||||||
|
|
||||||
triq_opts(Config) ->
|
triq_opts(Config) ->
|
||||||
|
|
|
@ -68,7 +68,7 @@ eunit(Config, _AppFile) ->
|
||||||
CodePath = setup_code_path(),
|
CodePath = setup_code_path(),
|
||||||
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
|
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
|
||||||
false),
|
false),
|
||||||
{ok, SrcErls} = rebar_erlc_compiler:test_compile(Config),
|
{ok, SrcErls} = rebar_erlc_compiler:test_compile(Config, "eunit"),
|
||||||
case CompileOnly of
|
case CompileOnly of
|
||||||
"true" ->
|
"true" ->
|
||||||
true = code:set_path(CodePath),
|
true = code:set_path(CodePath),
|
||||||
|
|
|
@ -119,7 +119,7 @@ run(Config, QC, QCOpts) ->
|
||||||
%% Compile erlang code to ?TEST_DIR, using a tweaked config
|
%% Compile erlang code to ?TEST_DIR, using a tweaked config
|
||||||
%% with appropriate defines, and include all the test modules
|
%% with appropriate defines, and include all the test modules
|
||||||
%% as well.
|
%% as well.
|
||||||
{ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config),
|
{ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config, "qc"),
|
||||||
|
|
||||||
case CompileOnly of
|
case CompileOnly of
|
||||||
"true" ->
|
"true" ->
|
||||||
|
|
Loading…
Reference in a new issue