summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <t@crashfast.com>2017-07-14 09:45:20 -0700
committerGitHub <noreply@github.com>2017-07-14 09:45:20 -0700
commitbaa369884ddc6d0449be76517fc292fe8d59aef5 (patch)
tree8f283648a5248ba3a99c1a013caeaf2ae0a9f06a
parent2326ad016c5e9ef941ae81e9b11a4cfedf15ff6f (diff)
parente4f5b55557c8f21b2526216cd38fea0aa91c53f0 (diff)
Merge pull request #1587 from tsloughter/ct-compile-only
add compile_only option to ct provider
-rw-r--r--src/rebar_prv_common_test.erl14
-rw-r--r--test/rebar_ct_SUITE.erl22
2 files changed, 32 insertions, 4 deletions
diff --git a/src/rebar_prv_common_test.erl b/src/rebar_prv_common_test.erl
index 3df8b75..dfade77 100644
--- a/src/rebar_prv_common_test.erl
+++ b/src/rebar_prv_common_test.erl
@@ -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) ->
diff --git a/test/rebar_ct_SUITE.erl b/test/rebar_ct_SUITE.erl
index 586e7b5..752db6c 100644
--- a/test/rebar_ct_SUITE.erl
+++ b/test/rebar_ct_SUITE.erl
@@ -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"