From 0bf08e4e34469144ae6f3297aae4a38b3bb2bd3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luis=20Rasc=C3=A3o?= Date: Sun, 25 Oct 2015 16:14:28 +0000 Subject: Add support for Windows integration testing Use retest feature/rebar-windows-ci branch that adds Windows tests support, test setup callback and additional touch command. For all tests copy rebar and rebar.cmd using retest setup callback. Port OS specific commands used in tests to Erlang (eg. touch, rm, cp, stat..). rebar_ct: do away with grep command line invocation (which doesn't exist in Windows) and use instead plain Erlang parsing. Increase timeout for rgen1 test to 4 minutes, Windows Appveyor can take longer than the previous 2 minutes. --- src/rebar_ct.erl | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/rebar_ct.erl b/src/rebar_ct.erl index 022dfc4..cf2059e 100644 --- a/src/rebar_ct.erl +++ b/src/rebar_ct.erl @@ -113,7 +113,12 @@ run_test(TestDir, LogDir, Config, _File) -> false -> " >> " ++ RawLog ++ " 2>&1"; true -> + case os:type() of + {win32, nt} -> + " >> " ++ RawLog ++ " 2>&1"; + _ -> " 2>&1 | tee -a " ++ RawLog + end end, ShOpts = [{env,[{"TESTDIR", TestDir}]}, return_on_error], @@ -155,14 +160,27 @@ failure_logger(Command, {Rc, Output}) -> check_fail_log(Config, RawLog, Command, Result) -> check_log(Config, RawLog, failure_logger(Command, Result)). -check_log(Config,RawLog,Fun) -> - {ok, Msg} = - rebar_utils:sh("grep -e \"TEST COMPLETE\" -e \"{error,make_failed}\" " - ++ RawLog, [{use_stdout, false}]), - MakeFailed = string:str(Msg, "{error,make_failed}") =/= 0, - RunFailed = string:str(Msg, ", 0 failed") =:= 0, +check_log(Config,RawLogFilename,Fun) -> + %% read the file and split into a list separated by newlines + {ok, RawLog} = file:read_file(RawLogFilename), + Msg = string:tokens(binary_to_list(RawLog), "\n"), + %% now filter out all the list entries that do not have test + %% completion strings + CompleteRuns = lists:filter(fun(M) -> + string:str(M, "TEST COMPLETE") =/= 0 + end, Msg), + MakeFailed = lists:filter(fun(M) -> + string:str(M, "{error,make_failed}") =/= 0 + end, Msg), + %% the run has failed if at least one of the tests failed + RunFailed = lists:foldl(fun(M, Acc) -> + %% the "0 failed" string must be present for + %% the test to be considered successful + TestFailed = string:str(M, "0 failed") =:= 0, + TestFailed orelse Acc + end, false, CompleteRuns), if - MakeFailed -> + MakeFailed =/= [] -> show_log(Config, RawLog), ?ERROR("Building tests failed\n",[]), ?FAIL; @@ -182,8 +200,7 @@ show_log(Config, RawLog) -> ?CONSOLE("Showing log\n", []), case rebar_log:is_verbose(Config) of false -> - {ok, Contents} = file:read_file(RawLog), - ?CONSOLE("~s", [Contents]); + ?CONSOLE("~s", [RawLog]); true -> ok end. -- cgit v1.2.1