diff options
author | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-09 13:58:32 +0200 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-09 14:04:53 +0200 |
commit | 99b645e4a3d57aba031487f56c4acfb7bf05fa16 (patch) | |
tree | bd7e1dd314c6b4e5cecad7130252871ef9ce66ac | |
parent | 803f6e8ecd6ef2e40e97cce6b514dd44279cd0f9 (diff) |
Separate eunit and qc compile options
-rw-r--r-- | rebar.config.sample | 21 | ||||
-rw-r--r-- | src/rebar_erlc_compiler.erl | 14 | ||||
-rw-r--r-- | src/rebar_eunit.erl | 2 | ||||
-rw-r--r-- | src/rebar_qc.erl | 2 |
4 files changed, 24 insertions, 15 deletions
diff --git a/rebar.config.sample b/rebar.config.sample index 4243924..bc4bc50 100644 --- a/rebar.config.sample +++ b/rebar.config.sample @@ -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 diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 7123395..561a2a6 100644 --- a/src/rebar_erlc_compiler.erl +++ b/src/rebar_erlc_compiler.erl @@ -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) -> diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl index 772c671..5e7f91c 100644 --- a/src/rebar_eunit.erl +++ b/src/rebar_eunit.erl @@ -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), diff --git a/src/rebar_qc.erl b/src/rebar_qc.erl index 1800540..0920a5b 100644 --- a/src/rebar_qc.erl +++ b/src/rebar_qc.erl @@ -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" -> |