diff options
Diffstat (limited to 'lib/eunit/src/eunit_surefire.erl')
-rw-r--r-- | lib/eunit/src/eunit_surefire.erl | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/eunit/src/eunit_surefire.erl b/lib/eunit/src/eunit_surefire.erl index 002a069a92..71f3765f21 100644 --- a/lib/eunit/src/eunit_surefire.erl +++ b/lib/eunit/src/eunit_surefire.erl @@ -95,6 +95,7 @@ start(Options) -> init(Options) -> XMLDir = proplists:get_value(dir, Options, ?XMLDIR), + ensure_xmldir(XMLDir), St = #state{verbose = proplists:get_bool(verbose, Options), xmldir = XMLDir, testsuites = []}, @@ -255,6 +256,19 @@ add_testcase_to_testsuite({error, Exception}, TestCaseTmp, TestSuite) -> testcases = [TestCase|TestSuite#testsuite.testcases] } end. +ensure_xmldir(XMLDir) -> + Steps = [ + fun filelib:ensure_dir/1, + fun file:make_dir/1], + lists:foldl(fun ensure_xmldir/2, XMLDir, Steps). + +ensure_xmldir(Fun, XMLDir) -> + case Fun(XMLDir) of + ok -> XMLDir; + {error, eexist} -> XMLDir; + {error, _Reason} = Error -> throw(Error) + end. + %% ---------------------------------------------------------------------------- %% Write a report to the XML directory. %% This function opens the report file, calls write_report_to/2 and closes the file. |