Common Test changes to add configurable log dir and improve testing framework overlaps. #175

Closed
wants to merge 1 commit into
from
View
7 rebar.config.sample
@@ -83,8 +83,11 @@
%% == Common Test ==
-%% Override the default "test" directory in which SUITEs are located
-{ct_dir, "itest"}.
+%% Override the default "ctest" directory in which SUITEs are located
+{ct_dir, "ctest"}.
+
+%% Override the default "logs" directory in which SUITEs are logged
+{ct_logs, "logs"}.
%% Option to pass extra parameters when launching Common Test
{ct_extra_params, "-boot start_sasl -s myapp"}.
View
23 src/rebar_ct.erl
@@ -46,24 +46,25 @@
%% ===================================================================
ct(Config, File) ->
- TestDir = rebar_config:get_local(Config, ct_dir, "test"),
- run_test_if_present(TestDir, Config, File).
+ TestDir = rebar_config:get_local(Config, ct_dir, "ctest"),
@tuncer
tuncer added a line comment Feb 16, 2012

Do we really want to change the default? @dizzyd, @joewilliams, @hyperthunk?

@DeadZen
DeadZen added a line comment Feb 16, 2012

The problem I noticed is that when running rebar ct any folder with a test directory would generate ct logs even without ct tests, having a more specific default for common tests would resolve this, to not change the default at all could be possible but would require a pre-step to check for *SUITEs first.

@tuncer
tuncer added a line comment Feb 16, 2012

Given how ct_run works, implementing the check for *_SUITE.erl is a better choice.

@DeadZen
DeadZen added a line comment Feb 16, 2012

yes, I concur. The distinction in the directory name was anecdotal after having made the logging directory configurable. Mainly a quick-fix to address both issues simultaneously, in this case pre-scanning for *_SUITE.erl is simple and direct with the common test suite naming convention. Also thank you for giving this your attention.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ LogsDir = rebar_config:get_local(Config, ct_logs, "logs"),
+ run_test_if_present(TestDir, LogsDir, Config, File).
%% ===================================================================
%% Internal functions
%% ===================================================================
-run_test_if_present(TestDir, Config, File) ->
+run_test_if_present(TestDir, LogsDir, Config, File) ->
case filelib:is_dir(TestDir) of
false ->
?WARN("~s directory not present - skipping\n", [TestDir]),
ok;
true ->
- run_test(TestDir, Config, File)
+ run_test(TestDir, LogsDir, Config, File)
end.
-run_test(TestDir, Config, _File) ->
- {Cmd, RawLog} = make_cmd(TestDir, Config),
- clear_log(RawLog),
+run_test(TestDir, LogsDir, Config, _File) ->
+ {Cmd, RawLog} = make_cmd(TestDir, LogsDir, Config),
+ clear_log(LogsDir, RawLog),
case rebar_config:is_verbose() of
false ->
Output = " >> " ++ RawLog ++ " 2>&1";
@@ -75,8 +76,8 @@ run_test(TestDir, Config, _File) ->
check_log(RawLog).
-clear_log(RawLog) ->
- case filelib:ensure_dir("logs/index.html") of
+clear_log(LogsDir, RawLog) ->
+ case filelib:ensure_dir(filename:join(LogsDir, "index.html")) of
ok ->
NowStr = rebar_utils:now_str(),
LogHeader = "--- Test run on " ++ NowStr ++ " ---\n",
@@ -120,9 +121,9 @@ show_log(RawLog) ->
ok
end.
-make_cmd(TestDir, Config) ->
+make_cmd(TestDir, LogsDir, Config) ->
Cwd = rebar_utils:get_cwd(),
- LogDir = filename:join(Cwd, "logs"),
+ LogDir = filename:join(Cwd, LogsDir),
EbinDir = filename:absname(filename:join(Cwd, "ebin")),
IncludeDir = filename:join(Cwd, "include"),
Include = case filelib:is_dir(IncludeDir) of