From ba954cfb43f0b05e15ee206b13488d62c3537267 Mon Sep 17 00:00:00 2001 From: Fred Hebert Date: Fri, 27 Jan 2017 21:30:18 -0500 Subject: 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. --- test/rebar_edoc_SUITE.erl | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/rebar_edoc_SUITE.erl') 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 -- cgit v1.1