diff options
author | DeadZen <deadzen@deadzen.com> | 2012-07-28 17:43:56 -0400 |
---|---|---|
committer | Tuncer Ayaz <tuncer.ayaz@gmail.com> | 2012-08-07 14:22:59 +0200 |
commit | f1d35f9d06e25f292f537217ce7f56034aabd432 (patch) | |
tree | fb4214832f431b4a8ab3df410a3af65e53d9ee84 /src | |
parent | 888bbc8ee2cabc75fda5dc3f7cf3a9d215042b71 (diff) |
Add ct_log_dir option, skip test dir with no SUITE
When rebar ct executes with its default common test directory of "test",
it will generate a hardcoded "logs" directory in every application with
a test directory present, causing an overlap with eunit's test framework
so even test directories with only eunit tests will be processed by ct.
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar_ct.erl | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl index d2f45c3..50efeb1 100644 --- a/src/rebar_ct.erl +++ b/src/rebar_ct.erl @@ -47,23 +47,31 @@ ct(Config, File) -> TestDir = rebar_config:get_local(Config, ct_dir, "test"), - run_test_if_present(TestDir, Config, File). + LogDir = rebar_config:get_local(Config, ct_log_dir, "logs"), + run_test_if_present(TestDir, LogDir, Config, File). %% =================================================================== %% Internal functions %% =================================================================== -run_test_if_present(TestDir, Config, File) -> +run_test_if_present(TestDir, LogDir, Config, File) -> case filelib:is_dir(TestDir) of false -> ?WARN("~s directory not present - skipping\n", [TestDir]), ok; true -> - run_test(TestDir, Config, File) + case filelib:wildcard(TestDir ++ "/*_SUITE.erl") of + [] -> + ?WARN("~s directory present, but no common_test" + ++ " SUITES - skipping\n", [TestDir]), + ok; + _ -> + run_test(TestDir, LogDir, Config, File) + end end. -run_test(TestDir, Config, _File) -> - {Cmd, RawLog} = make_cmd(TestDir, Config), - clear_log(RawLog), +run_test(TestDir, LogDir, Config, _File) -> + {Cmd, RawLog} = make_cmd(TestDir, LogDir, Config), + clear_log(LogDir, RawLog), case rebar_config:is_verbose(Config) of false -> Output = " >> " ++ RawLog ++ " 2>&1"; @@ -75,8 +83,8 @@ run_test(TestDir, Config, _File) -> check_log(Config, RawLog). -clear_log(RawLog) -> - case filelib:ensure_dir("logs/index.html") of +clear_log(LogDir, RawLog) -> + case filelib:ensure_dir(filename:join(LogDir, "index.html")) of ok -> NowStr = rebar_utils:now_str(), LogHeader = "--- Test run on " ++ NowStr ++ " ---\n", @@ -120,9 +128,9 @@ show_log(Config, RawLog) -> ok end. -make_cmd(TestDir, Config) -> +make_cmd(TestDir, RawLogDir, Config) -> Cwd = rebar_utils:get_cwd(), - LogDir = filename:join(Cwd, "logs"), + LogDir = filename:join(Cwd, RawLogDir), EbinDir = filename:absname(filename:join(Cwd, "ebin")), IncludeDir = filename:join(Cwd, "include"), Include = case filelib:is_dir(IncludeDir) of |