diff --git a/test/test_helper.erl b/test/test_helper.erl index 16fa21e..77aba35 100644 --- a/test/test_helper.erl +++ b/test/test_helper.erl @@ -42,6 +42,26 @@ stop_riak() -> load_and_start_apps([]) -> ok; load_and_start_apps([App|Tail]) -> - application:load(App), - application:start(App), + ensure_loaded(App), + ensure_started(App), load_and_start_apps(Tail). + +ensure_loaded(App) -> + case application:load(App) of + ok -> + ok; + {error,{already_loaded,App}} -> + ok; + Error -> + throw({"failed to load", App, Error}) + end. + +ensure_started(App) -> + case application:start(App) of + ok -> + ok; + {error,{already_started,App}} -> + ok; + Error -> + throw({"failed to start", App, Error}) + end.