summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuis Rascão <luis.rascao@gmail.com>2015-10-25 16:14:28 +0000
committerLuis Rascão <luis.rascao@gmail.com>2016-01-15 15:03:33 +0000
commit0bf08e4e34469144ae6f3297aae4a38b3bb2bd3c (patch)
tree13c1467bb7f754c25afec85fbb25775e0bc4e2bf /src
parent6f07a636d8f309caef7c68e576396ce3328075ea (diff)
downloadrebar-0bf08e4e34469144ae6f3297aae4a38b3bb2bd3c.tar.gz
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.
Diffstat (limited to 'src')
-rw-r--r--src/rebar_ct.erl35
1 files changed, 26 insertions, 9 deletions
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.