Replace test-compile with compile_only=true option

This commit is contained in:
Tuncer Ayaz 2012-08-09 13:25:01 +02:00
parent 87904ceef2
commit 803f6e8ecd
6 changed files with 44 additions and 26 deletions

View file

@ -1,2 +1,2 @@
rebar_utils.erl:163: Call to missing or unexported function escript:foldl/3 rebar_utils.erl:164: Call to missing or unexported function escript:foldl/3

View file

@ -10,8 +10,8 @@ _rebar()
lopts=" --help --commands --verbose --force --jobs= --version" lopts=" --help --commands --verbose --force --jobs= --version"
cmdsnvars="check-deps clean compile create create-app create-node ct \ cmdsnvars="check-deps clean compile create create-app create-node ct \
doc delete-deps escriptize eunit get-deps generate generate-upgrade \ doc delete-deps escriptize eunit get-deps generate generate-upgrade \
help list-deps list-templates qc test-compile update-deps version \ help list-deps list-templates qc update-deps version xref overlay \
xref overlay apps= case= force=1 jobs= suites= verbose=1 appid= \ overlay apps= case= force=1 jobs= suites= verbose=1 appid= \
previous_release= nodeid= root_dir= skip_deps=true skip_apps= \ previous_release= nodeid= root_dir= skip_deps=true skip_apps= \
template= template_dir=" template= template_dir="

View file

@ -297,7 +297,6 @@ generate-upgrade previous_release=path Build an upgrade package
generate-appups previous_release=path Generate appup files generate-appups previous_release=path Generate appup files
test-compile Compile sources for eunit/qc run
eunit [suites=foo] Run eunit [test/foo_tests.erl] tests eunit [suites=foo] Run eunit [test/foo_tests.erl] tests
ct [suites=] [case=] Run common_test suites ct [suites=] [case=] Run common_test suites
@ -366,8 +365,7 @@ command_names() ->
["check-deps", "clean", "compile", "create", "create-app", "create-node", ["check-deps", "clean", "compile", "create", "create-app", "create-node",
"ct", "delete-deps", "doc", "eunit", "generate", "generate-appups", "ct", "delete-deps", "doc", "eunit", "generate", "generate-appups",
"generate-upgrade", "get-deps", "help", "list-deps", "list-templates", "generate-upgrade", "get-deps", "help", "list-deps", "list-templates",
"test-compile", "qc", "update-deps", "overlay", "shell", "version", "qc", "update-deps", "overlay", "shell", "version", "xref"].
"xref"].
unabbreviate_command_names([]) -> unabbreviate_command_names([]) ->
[]; [];

View file

@ -54,8 +54,7 @@
-module(rebar_eunit). -module(rebar_eunit).
-export([eunit/2, -export([eunit/2,
clean/2, clean/2]).
'test-compile'/2]).
-include("rebar.hrl"). -include("rebar.hrl").
@ -67,9 +66,25 @@ eunit(Config, _AppFile) ->
ok = ensure_dirs(), ok = ensure_dirs(),
%% Save code path %% Save code path
CodePath = setup_code_path(), 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),
case CompileOnly of
"true" ->
true = code:set_path(CodePath),
?CONSOLE("Compiled modules for eunit~n", []);
false ->
run_eunit(Config, CodePath, SrcErls)
end.
clean(_Config, _File) ->
rebar_file_utils:rm_rf(?TEST_DIR).
%% ===================================================================
%% Internal functions
%% ===================================================================
run_eunit(Config, CodePath, SrcErls) ->
%% Build a list of all the .beams in ?TEST_DIR -- use this for %% Build a list of all the .beams in ?TEST_DIR -- use this for
%% cover and eunit testing. Normally you can just tell cover %% cover and eunit testing. Normally you can just tell cover
%% and/or eunit to scan the directory for you, but eunit does a %% and/or eunit to scan the directory for you, but eunit does a
@ -128,23 +143,6 @@ eunit(Config, _AppFile) ->
true = code:set_path(CodePath), true = code:set_path(CodePath),
ok. ok.
clean(_Config, _File) ->
rebar_file_utils:rm_rf(?TEST_DIR).
'test-compile'(Config, _File) ->
?CONSOLE("NOTICE: Using experimental 'test-compile' command~n", []),
ok = ensure_dirs(),
%% Save code path
CodePath = setup_code_path(),
{ok, _SrcErls} = rebar_erlc_compiler:test_compile(Config),
%% Restore code path
true = code:set_path(CodePath),
ok.
%% ===================================================================
%% Internal functions
%% ===================================================================
ensure_dirs() -> ensure_dirs() ->
%% Make sure ?TEST_DIR/ and ebin/ directory exists (append dummy module) %% Make sure ?TEST_DIR/ and ebin/ directory exists (append dummy module)
ok = filelib:ensure_dir(filename:join(rebar_utils:test_dir(), "dummy")), ok = filelib:ensure_dir(filename:join(rebar_utils:test_dir(), "dummy")),

View file

@ -114,11 +114,22 @@ run(Config, QC, QCOpts) ->
ok = filelib:ensure_dir(?TEST_DIR ++ "/foo"), ok = filelib:ensure_dir(?TEST_DIR ++ "/foo"),
CodePath = setup_codepath(), CodePath = setup_codepath(),
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
false),
%% 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),
case CompileOnly of
"true" ->
true = code:set_path(CodePath),
?CONSOLE("Compiled modules for qc~n", []);
false ->
run1(QC, QCOpts, CodePath)
end.
run1(QC, QCOpts, CodePath) ->
TestModule = fun(M) -> qc_module(QC, QCOpts, M) end, TestModule = fun(M) -> qc_module(QC, QCOpts, M) end,
case lists:flatmap(TestModule, find_prop_mods()) of case lists:flatmap(TestModule, find_prop_mods()) of
[] -> [] ->

View file

@ -45,6 +45,7 @@
vcs_vsn/3, vcs_vsn/3,
deprecated/3, deprecated/4, deprecated/3, deprecated/4,
get_deprecated_global/4, get_deprecated_global/5, get_deprecated_global/4, get_deprecated_global/5,
get_experimental_global/3,
get_deprecated_list/4, get_deprecated_list/5, get_deprecated_list/4, get_deprecated_list/5,
get_deprecated_local/4, get_deprecated_local/5, get_deprecated_local/4, get_deprecated_local/5,
delayed_halt/1, delayed_halt/1,
@ -230,6 +231,16 @@ get_deprecated_global(Config, OldOpt, NewOpt, Default, When) ->
New New
end. end.
get_experimental_global(Config, Opt, Default) ->
Val = rebar_config:get_global(Config, Opt, Default),
case Val of
Default ->
Default;
Val ->
?CONSOLE("NOTICE: Using experimental option '~p'~n", [Opt]),
Val
end.
get_deprecated_list(Config, OldOpt, NewOpt, When) -> get_deprecated_list(Config, OldOpt, NewOpt, When) ->
get_deprecated_list(Config, OldOpt, NewOpt, undefined, When). get_deprecated_list(Config, OldOpt, NewOpt, undefined, When).