Updated Branches: refs/heads/master 178f77fa3 -> d7f20376b
COUCHDB-1424 Fix etap to not consume any message Turns out that etap consumes any message in the mailbox in some cases. This can make some tests that use message passing hang, as etap itself consumes the messages. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/d7f20376 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/d7f20376 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/d7f20376 Branch: refs/heads/master Commit: d7f20376b1a880ba45e0a2699de2dd66df82f671 Parents: 178f77f Author: Filipe David Borba Manana <[email protected]> Authored: Wed Oct 31 16:19:48 2012 +0100 Committer: Jan Lehnardt <[email protected]> Committed: Tue Nov 13 20:53:16 2012 +0100 ---------------------------------------------------------------------- src/etap/etap.erl | 21 +++++++++++---------- 1 files changed, 11 insertions(+), 10 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/d7f20376/src/etap/etap.erl ---------------------------------------------------------------------- diff --git a/src/etap/etap.erl b/src/etap/etap.erl index 7380013..ae3896c 100644 --- a/src/etap/etap.erl +++ b/src/etap/etap.erl @@ -120,14 +120,14 @@ plan(N) when is_integer(N), N > 0 -> %% @doc End the current test plan and output test results. %% @todo This should probably be done in the test_server process. end_tests() -> - timer:sleep(100), + Ref = make_ref(), case whereis(etap_server) of - undefined -> self() ! true; - _ -> etap_server ! {self(), state} + undefined -> self() ! {Ref, true}; + _ -> etap_server ! {self(), state, Ref} end, - State = receive X -> X end, + State = receive {Ref, X} -> X end, if - State#test_state.planned == -1 -> + is_record(State, test_state) andalso State#test_state.planned == -1 -> io:format("1..~p~n", [State#test_state.count]); true -> ok @@ -564,8 +564,8 @@ test_server(State) -> count = State#test_state.count + 1, fail = State#test_state.fail + 1 }; - {From, state} -> - From ! State, + {From, state, Ref} -> + From ! {Ref, State}, State; {_From, diag, Message} -> io:format("~s~n", [Message]), @@ -573,8 +573,8 @@ test_server(State) -> {From, count} -> From ! State#test_state.count, State; - {From, is_skip} -> - From ! State#test_state.skip, + {From, is_skip, Ref} -> + From ! {Ref, State#test_state.skip}, State; done -> exit(normal) @@ -584,7 +584,8 @@ test_server(State) -> %% @private %% @doc Process the result of a test and send it to the etap_server process. mk_tap(Result, Desc) -> - IsSkip = lib:sendw(etap_server, is_skip), + etap_server ! {self(), is_skip, Ref = make_ref()} , + receive {Ref, IsSkip} -> ok end, case [IsSkip, Result] of [_, true] -> etap_server ! {self(), pass, Desc},
