summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorArjan Scherpenisse <arjan@scherpenisse.net>2012-08-01 20:47:47 +0200
committerDave Smith <dizzyd@dizzyd.com>2012-10-31 20:37:42 -0600
commitcc67814b657380507c3aee1222f9f2c8b8b061b4 (patch)
tree0cb91b92f7f731ada3a4549d7a0b341a854a5534 /src
parent380506c38031722e928bacf1c5f143e5655ab349 (diff)
ct: skip instead of halt on missing/unknown suite
This allows `rebar ct suites=abc` to consider all suites when you have a rebar setup with multiple sub_dirs. Previously, rebar halted after it could not find the suite in the first dir. But the suite might be present in another dir (when sub_dirs contains multiple dirs). This commit makes it so instead of halting, it prints a warning and continues with looking for the suite in the other `sub_dir`s. Note -- This uses try/catch to cause the test to be skipped because otherwise I needed to adjust the return values of 4 functions, the code path is pretty deeply nested here. Otherwise the whole call chain needed to be adjusted for this return value: `run_test -> make_cmd -> get_suites -> find_suite_path` IMHO, I think for exceptional cases like this it is fine to use throw; specially since only the {skip} is catched and nothing else.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_ct.erl13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl
index 6fd5bc7..e33c6c9 100644
--- a/src/rebar_ct.erl
+++ b/src/rebar_ct.erl
@@ -65,7 +65,12 @@ run_test_if_present(TestDir, LogDir, Config, File) ->
++ " SUITES - skipping\n", [TestDir]),
ok;
_ ->
- run_test(TestDir, LogDir, Config, File)
+ try
+ run_test(TestDir, LogDir, Config, File)
+ catch
+ throw:skip ->
+ ok
+ end
end
end.
@@ -270,8 +275,10 @@ find_suite_path(Suite, TestDir) ->
Path = filename:join(TestDir, Suite ++ "_SUITE.erl"),
case filelib:is_regular(Path) of
false ->
- ?ERROR("Suite ~s not found\n", [Suite]),
- ?FAIL;
+ ?WARN("Suite ~s not found\n", [Suite]),
+ %% Note - this throw is caught in run_test_if_present/3;
+ %% this solution was easier than refactoring the entire module.
+ throw(skip);
true ->
Path
end.