From 4802c0a6cac1aae2a6fc43a57d6cbd5c09fc4050 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Rasc=C3=A3o?= Date: Fri, 12 Feb 2016 13:15:30 +0000 Subject: Optionally look for ct .spec files in the ct_dir that was specified Allow to change existing behaviour which is to find all .spec files recursively in the current working directory through a new rebar.config option: {ct_search_specs_from_test_dir, true} This is confusing since the user explicitly stated the location for his spec files and negates the possibility to have different spec'ed suites for different environment. Also fix the node name generation on the ct test run, append a random number that will reduce chances of name collisions on epmd. --- src/rebar_ct.erl | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl index cf2059e..b27f661 100644 --- a/src/rebar_ct.erl +++ b/src/rebar_ct.erl @@ -66,6 +66,7 @@ info(help, ct) -> " ~p~n" " ~p~n" " ~p~n" + " ~p~n" "Valid command line options:~n" " suites=Suite1,Suite2,...,SuiteN~n" " - run Suite1_SUITE, Suite2_SUITE, ..., SuiteN_SUITE~n" @@ -81,7 +82,8 @@ info(help, ct) -> {ct_dir, "itest"}, {ct_log_dir, "test/logs"}, {ct_extra_params, "-boot start_sasl -s myapp"}, - {ct_use_short_names, true} + {ct_use_short_names, true}, + {ct_search_specs_from_test_dir, false} ]). run_test_if_present(TestDir, LogDir, Config, File) -> @@ -235,7 +237,7 @@ make_cmd(TestDir, RawLogDir, Config) -> CodeDirs = [io_lib:format("\"~s\"", [Dir]) || Dir <- [EbinDir|NonLibCodeDirs]], CodePathString = string:join(CodeDirs, " "), - Cmd = case get_ct_specs(Config, Cwd) of + Cmd = case get_ct_specs(Config, search_ct_specs_from(Cwd, TestDir, Config)) of undefined -> ?FMT("~s" " -pa ~s" @@ -276,10 +278,20 @@ make_cmd(TestDir, RawLogDir, Config) -> RawLog = filename:join(LogDir, "raw.log"), {Cmd, RawLog}. +search_ct_specs_from(Cwd, TestDir, Config) -> + case rebar_config:get_local(Config, ct_search_specs_from_test_dir, false) of + true -> filename:join(Cwd, TestDir); + false -> + Cwd + end. + build_name(Config) -> + %% generate a unique name for our test node, we want + %% to make sure the odds of name clashing are low + Random = integer_to_list(crypto:rand_uniform(0, 10000)), case rebar_config:get_local(Config, ct_use_short_names, false) of - true -> "-sname test"; - false -> " -name test@" ++ net_adm:localhost() + true -> "-sname test" ++ Random; + false -> " -name test" ++ Random ++ "@" ++ net_adm:localhost() end. get_extra_params(Config) -> -- cgit v1.2.1