summaryrefslogtreecommitdiff
path: root/test/rebar_edoc_SUITE.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2017-01-27 21:30:18 -0500
committerFred Hebert <mononcqc@ferd.ca>2017-01-27 22:21:17 -0500
commitba954cfb43f0b05e15ee206b13488d62c3537267 (patch)
tree92dea83e69ed2b9717981c2838adf82c501cbce1 /test/rebar_edoc_SUITE.erl
parentabff9dfff34e04bd23b1f178eadee4d8770de9a9 (diff)
Survive EDoc crashes
Instead of a hard crash, display an error message indicating which app failed. We can't report the exact failure; only EDoc does it to stdout itself and we can't capture it. Pre/Post hooks are run properly despite the failure, as per escript and compile providers.
Diffstat (limited to 'test/rebar_edoc_SUITE.erl')
-rw-r--r--test/rebar_edoc_SUITE.erl22
1 files changed, 21 insertions, 1 deletions
diff --git a/test/rebar_edoc_SUITE.erl b/test/rebar_edoc_SUITE.erl
index fded2b0..2c4aba5 100644
--- a/test/rebar_edoc_SUITE.erl
+++ b/test/rebar_edoc_SUITE.erl
@@ -3,7 +3,7 @@
-include_lib("eunit/include/eunit.hrl").
-compile(export_all).
-all() -> [multiapp].
+all() -> [multiapp, error_survival].
init_per_testcase(multiapp, Config) ->
application:load(rebar),
@@ -16,6 +16,18 @@ init_per_testcase(multiapp, Config) ->
rebar_log:init(command_line, Verbosity),
State = rebar_state:new([{base_dir, filename:join([AppsDir, "_build"])}
,{root_dir, AppsDir}]),
+ [{apps, AppsDir}, {state, State}, {name, Name} | Config];
+init_per_testcase(error_survival, Config) ->
+ application:load(rebar),
+ DataDir = ?config(data_dir, Config),
+ PrivDir = ?config(priv_dir, Config),
+ Name = rebar_test_utils:create_random_name("error_survival"),
+ AppsDir = filename:join([PrivDir, rebar_test_utils:create_random_name(Name)]),
+ ec_file:copy(filename:join([DataDir, "bad"]), AppsDir, [recursive]),
+ Verbosity = rebar3:log_level(),
+ rebar_log:init(command_line, Verbosity),
+ State = rebar_state:new([{base_dir, filename:join([AppsDir, "_build"])}
+ ,{root_dir, AppsDir}]),
[{apps, AppsDir}, {state, State}, {name, Name} | Config].
end_per_testcase(_, Config) ->
@@ -42,6 +54,14 @@ multiapp(Config) ->
filename:join([AppsDir, "apps", "foo", "doc", "foo.html"]),
"apps/bar1/doc/bar1.html")).
+error_survival(Config) ->
+ RebarConfig = [],
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig, ["edoc"],
+ {error,{rebar_prv_edoc,{app_failed,"bar2"}}}
+ ),
+ ok.
+
file_content_matches(Path, Regex) ->
case file:read_file(Path) of