mirror of
https://github.com/correl/rebar.git
synced 2024-12-24 03:00:16 +00:00
Replace test-compile with compile_only=true option
This commit is contained in:
parent
87904ceef2
commit
803f6e8ecd
6 changed files with 44 additions and 26 deletions
|
@ -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
|
||||
|
|
|
@ -10,8 +10,8 @@ _rebar()
|
|||
lopts=" --help --commands --verbose --force --jobs= --version"
|
||||
cmdsnvars="check-deps clean compile create create-app create-node ct \
|
||||
doc delete-deps escriptize eunit get-deps generate generate-upgrade \
|
||||
help list-deps list-templates qc test-compile update-deps version \
|
||||
xref overlay apps= case= force=1 jobs= suites= verbose=1 appid= \
|
||||
help list-deps list-templates qc update-deps version xref overlay \
|
||||
overlay apps= case= force=1 jobs= suites= verbose=1 appid= \
|
||||
previous_release= nodeid= root_dir= skip_deps=true skip_apps= \
|
||||
template= template_dir="
|
||||
|
||||
|
|
|
@ -297,7 +297,6 @@ generate-upgrade previous_release=path Build an upgrade package
|
|||
|
||||
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
|
||||
ct [suites=] [case=] Run common_test suites
|
||||
|
||||
|
@ -366,8 +365,7 @@ command_names() ->
|
|||
["check-deps", "clean", "compile", "create", "create-app", "create-node",
|
||||
"ct", "delete-deps", "doc", "eunit", "generate", "generate-appups",
|
||||
"generate-upgrade", "get-deps", "help", "list-deps", "list-templates",
|
||||
"test-compile", "qc", "update-deps", "overlay", "shell", "version",
|
||||
"xref"].
|
||||
"qc", "update-deps", "overlay", "shell", "version", "xref"].
|
||||
|
||||
unabbreviate_command_names([]) ->
|
||||
[];
|
||||
|
|
|
@ -54,8 +54,7 @@
|
|||
-module(rebar_eunit).
|
||||
|
||||
-export([eunit/2,
|
||||
clean/2,
|
||||
'test-compile'/2]).
|
||||
clean/2]).
|
||||
|
||||
-include("rebar.hrl").
|
||||
|
||||
|
@ -67,9 +66,25 @@ eunit(Config, _AppFile) ->
|
|||
ok = ensure_dirs(),
|
||||
%% Save code path
|
||||
CodePath = setup_code_path(),
|
||||
|
||||
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
|
||||
false),
|
||||
{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
|
||||
%% cover and eunit testing. Normally you can just tell cover
|
||||
%% 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),
|
||||
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() ->
|
||||
%% Make sure ?TEST_DIR/ and ebin/ directory exists (append dummy module)
|
||||
ok = filelib:ensure_dir(filename:join(rebar_utils:test_dir(), "dummy")),
|
||||
|
|
|
@ -114,11 +114,22 @@ run(Config, QC, QCOpts) ->
|
|||
ok = filelib:ensure_dir(?TEST_DIR ++ "/foo"),
|
||||
CodePath = setup_codepath(),
|
||||
|
||||
CompileOnly = rebar_utils:get_experimental_global(Config, compile_only,
|
||||
false),
|
||||
%% 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),
|
||||
|
||||
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,
|
||||
case lists:flatmap(TestModule, find_prop_mods()) of
|
||||
[] ->
|
||||
|
|
|
@ -45,6 +45,7 @@
|
|||
vcs_vsn/3,
|
||||
deprecated/3, deprecated/4,
|
||||
get_deprecated_global/4, get_deprecated_global/5,
|
||||
get_experimental_global/3,
|
||||
get_deprecated_list/4, get_deprecated_list/5,
|
||||
get_deprecated_local/4, get_deprecated_local/5,
|
||||
delayed_halt/1,
|
||||
|
@ -230,6 +231,16 @@ get_deprecated_global(Config, OldOpt, NewOpt, Default, When) ->
|
|||
New
|
||||
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, undefined, When).
|
||||
|
||||
|
|
Loading…
Reference in a new issue