From e47d643ea3b490fd4835629e86d90fa3121122de Mon Sep 17 00:00:00 2001 From: Tuncer Ayaz Date: Thu, 9 Aug 2012 18:37:26 +0200 Subject: Use separate dirs for eunit and qc --- dialyzer_reference | 2 +- include/rebar.hrl | 2 -- src/rebar_erlc_compiler.erl | 18 +++++++++--------- src/rebar_eunit.erl | 40 +++++++++++++++++++++++----------------- src/rebar_qc.erl | 17 +++++++++++------ src/rebar_utils.erl | 4 ---- test/rebar_eunit_tests.erl | 26 +++++++++++++------------- 7 files changed, 57 insertions(+), 52 deletions(-) diff --git a/dialyzer_reference b/dialyzer_reference index 72a8077..be486b5 100644 --- a/dialyzer_reference +++ b/dialyzer_reference @@ -1,2 +1,2 @@ -rebar_utils.erl:164: Call to missing or unexported function escript:foldl/3 +rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3 diff --git a/include/rebar.hrl b/include/rebar.hrl index b338fc2..58debfc 100644 --- a/include/rebar.hrl +++ b/include/rebar.hrl @@ -12,5 +12,3 @@ -define(ERROR(Str, Args), rebar_log:log(error, Str, Args)). -define(FMT(Str, Args), lists:flatten(io_lib:format(Str, Args))). - --define(TEST_DIR, ".test"). diff --git a/src/rebar_erlc_compiler.erl b/src/rebar_erlc_compiler.erl index 561a2a6..84b9e85 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/2]). +-export([test_compile/3]). -include("rebar.hrl"). @@ -114,7 +114,7 @@ clean(_Config, _AppFile) -> %% .erl Compilation API (externally used by only eunit and qc) %% =================================================================== -test_compile(Config, Cmd) -> +test_compile(Config, Cmd, OutDir) -> %% 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"]}]} @@ -133,16 +133,16 @@ test_compile(Config, Cmd) -> end, [], SrcDirs), %% If it is not the first time rebar eunit is executed, there will be source - %% files already present in ?TEST_DIR. Since some SCMs (like Perforce) set + %% files already present in OutDir. Since some SCMs (like Perforce) set %% the source files as being read only (unless they are checked out), we - %% need to be sure that the files already present in ?TEST_DIR are writable + %% need to be sure that the files already present in OutDir are writable %% before doing the copy. This is done here by removing any file that was %% already present before calling rebar_file_utils:cp_r. - %% Get the full path to a file that was previously copied in ?TEST_DIR + %% Get the full path to a file that was previously copied in OutDir ToCleanUp = fun(F, Acc) -> F2 = filename:basename(F), - F3 = filename:join([?TEST_DIR, F2]), + F3 = filename:join([OutDir, F2]), case filelib:is_regular(F3) of true -> [F3|Acc]; false -> Acc @@ -152,12 +152,12 @@ test_compile(Config, Cmd) -> ok = rebar_file_utils:delete_each(lists:foldl(ToCleanUp, [], TestErls)), ok = rebar_file_utils:delete_each(lists:foldl(ToCleanUp, [], SrcErls)), - ok = rebar_file_utils:cp_r(SrcErls ++ TestErls, ?TEST_DIR), + ok = rebar_file_utils:cp_r(SrcErls ++ TestErls, OutDir), - %% Compile erlang code to ?TEST_DIR, using a tweaked config + %% Compile erlang code to OutDir, using a tweaked config %% with appropriate defines for eunit, and include all the test modules %% as well. - ok = doterl_compile(test_compile_config(Config, Cmd), ?TEST_DIR, TestErls), + ok = doterl_compile(test_compile_config(Config, Cmd), OutDir, TestErls), {ok, SrcErls}. diff --git a/src/rebar_eunit.erl b/src/rebar_eunit.erl index 5e7f91c..8846d97 100644 --- a/src/rebar_eunit.erl +++ b/src/rebar_eunit.erl @@ -28,7 +28,7 @@ %% @doc rebar_eunit supports the following commands: %%