Browse Source

Merge pull request #1587 from tsloughter/ct-compile-only

add compile_only option to ct provider
pull/1588/head
Tristan Sloughter 7 years ago
committed by GitHub
parent
commit
baa369884d
2 changed files with 32 additions and 4 deletions
  1. +12
    -2
      src/rebar_prv_common_test.erl
  2. +20
    -2
      test/rebar_ct_SUITE.erl

+ 12
- 2
src/rebar_prv_common_test.erl View File

@ -41,7 +41,14 @@ do(State) ->
Tests = prepare_tests(State),
case compile(State, Tests) of
%% successfully compiled apps
{ok, S} -> do(S, Tests);
{ok, S} ->
{RawOpts, _} = rebar_state:command_parsed_args(S),
case proplists:get_value(compile_only, RawOpts, false) of
true ->
{ok, S};
false ->
do(S, Tests)
end;
%% this should look like a compiler error, not a ct error
Error -> Error
end.
@ -743,9 +750,12 @@ ct_opts(_State) ->
{name, undefined, "name", atom, help(name)},
{sname, undefined, "sname", atom, help(sname)},
{setcookie, undefined, "setcookie", atom, help(setcookie)},
{sys_config, undefined, "sys_config", string, help(sys_config)} %% comma-separated list
{sys_config, undefined, "sys_config", string, help(sys_config)}, %% comma-separated list
{compile_only, undefined, "compile_only", boolean, help(compile_only)}
].
help(compile_only) ->
"Compile modules in the project with the test configuration but do not run the tests";
help(dir) ->
"List of additional directories containing test suites";
help(suite) ->

+ 20
- 2
test/rebar_ct_SUITE.erl View File

@ -56,7 +56,8 @@
testspec_at_root/1,
testspec_parse_error/1,
cmd_vs_cfg_opts/1,
single_testspec_in_ct_opts/1]).
single_testspec_in_ct_opts/1,
compile_only/1]).
-include_lib("eunit/include/eunit.hrl").
-include_lib("common_test/include/ct.hrl").
@ -77,7 +78,8 @@ all() -> [{group, basic_app},
testspec_at_root,
testspec_parse_error,
cmd_vs_cfg_opts,
single_testspec_in_ct_opts].
single_testspec_in_ct_opts,
compile_only].
groups() -> [{basic_app, [], [basic_app_default_dirs,
basic_app_default_beams,
@ -1585,6 +1587,22 @@ single_testspec_in_ct_opts(Config) ->
ok = file:set_cwd(Wd),
ok.
compile_only(Config) ->
C = rebar_test_utils:init_rebar_state(Config, "compile_only_"),
AppDir = ?config(apps, C),
Name = rebar_test_utils:create_random_name(atom_to_list(basic_app) ++ "_"),
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
Suite = filename:join([AppDir, "test", Name ++ "_SUITE.erl"]),
ok = filelib:ensure_dir(Suite),
ok = file:write_file(Suite, test_suite(Name)),
{ok, _State} = rebar_test_utils:run_and_check(C, [], ["ct", "--compile_only"], {ok, [{app,Name}], "test"}).
%% helper for generating test data
test_suite(Name) ->
io_lib:format("-module(~ts_SUITE).\n"

Loading…
Cancel
Save