Separate eunit and qc compile options

This commit is contained in:
Tuncer Ayaz 2012-08-09 13:58:32 +02:00
parent 803f6e8ecd
commit 99b645e4a3
4 changed files with 24 additions and 15 deletions

View file

@ -22,13 +22,6 @@
{platform_define, "(linux|freebsd)", 'BACKLOG', 128},
{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_opts, []}.
@ -72,6 +65,14 @@
%% Options for eunit:test()
{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'
{cover_enabled, false}.
@ -100,6 +101,12 @@
%% If qc_mod is unspecified, rebar tries to detect Triq or EQC
{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 ==
%% Which files to cleanup

View file

@ -30,7 +30,7 @@
clean/2]).
%% for internal use by only eunit and qc
-export([test_compile/1]).
-export([test_compile/2]).
-include("rebar.hrl").
@ -114,7 +114,7 @@ clean(_Config, _AppFile) ->
%% .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.
%% Notice: this could also be achieved with the following
%% 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
%% with appropriate defines for eunit, and include all the test modules
%% 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}.
@ -165,19 +165,21 @@ test_compile(Config) ->
%% Internal functions
%% ===================================================================
test_compile_config(Config) ->
test_compile_config(Config, Cmd) ->
{Config1, TriqOpts} = triq_opts(Config),
{Config2, PropErOpts} = proper_opts(Config1),
{Config3, EqcOpts} = eqc_opts(Config2),
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'}] ++
ErlOpts ++ EunitOpts ++ TriqOpts ++ PropErOpts ++ EqcOpts,
Opts = [O || O <- Opts0, O =/= no_debug_info],
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).
triq_opts(Config) ->

View file

@ -68,7 +68,7 @@ eunit(Config, _AppFile) ->
CodePath = setup_code_path(),
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
false),
{ok, SrcErls} = rebar_erlc_compiler:test_compile(Config),
{ok, SrcErls} = rebar_erlc_compiler:test_compile(Config, "eunit"),
case CompileOnly of
"true" ->
true = code:set_path(CodePath),

View file

@ -119,7 +119,7 @@ run(Config, QC, QCOpts) ->
%% Compile erlang code to ?TEST_DIR, using a tweaked config
%% with appropriate defines, and include all the test modules
%% as well.
{ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config),
{ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config, "qc"),
case CompileOnly of
"true" ->