Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/processone/ejabberd.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorPaweł Chmielowski <pawel@process-one.net>2015-02-04 16:42:03 +0300
committerPaweł Chmielowski <pawel@process-one.net>2015-04-09 17:05:26 +0300
commit2797fa16a6fb58dc1ca111f633cd4838c1895a88 (patch)
tree0fea2b4cd9cdc9bf6a6f75017980ff302738bafa /test
parent8732817c3cb770f948404a4a481667d286541c7a (diff)
Show received input and expected input in ?recv* macros in case of failure
Throwing catch clause error is not that good for finding out what happened
Diffstat (limited to 'test')
-rw-r--r--test/suite.erl3
-rw-r--r--test/suite.hrl14
2 files changed, 13 insertions, 4 deletions
diff --git a/test/suite.erl b/test/suite.erl
index a50bb64df..75fb15a7b 100644
--- a/test/suite.erl
+++ b/test/suite.erl
@@ -175,6 +175,9 @@ re_register(Config) ->
{atomic, ok} = ejabberd_auth:try_register(User, Server, Pass),
ok.
+match_failure(Received, Matches) ->
+ ct:fail("Received input:~n~n~p~n~ndon't match expected patterns:~n~n~p", [Received, Matches]).
+
recv() ->
receive
{'$gen_event', {xmlstreamelement, El}} ->
diff --git a/test/suite.hrl b/test/suite.hrl
index 269620179..31e21ee5f 100644
--- a/test/suite.hrl
+++ b/test/suite.hrl
@@ -21,7 +21,10 @@
(fun() ->
case {R1 = recv(), R2 = recv()} of
{P1, P2} -> {R1, R2};
- {P2, P1} -> {R2, R1}
+ {P2, P1} -> {R2, R1};
+ {P1, V1} -> suite:match_failure([V1], [P2]);
+ {P2, V2} -> suite:match_failure([V2], [P1]);
+ {V3, V4} -> suite:match_failure([V3, V4], [P1, P2])
end
end)()).
@@ -30,7 +33,8 @@
case R3 = recv() of
P1 -> insert(R3, 1, ?recv2(P2, P3));
P2 -> insert(R3, 2, ?recv2(P1, P3));
- P3 -> insert(R3, 3, ?recv2(P1, P2))
+ P3 -> insert(R3, 3, ?recv2(P1, P2));
+ V -> suite:match_failure([V], [P1, P2, P3])
end
end)()).
@@ -40,7 +44,8 @@
P1 -> insert(R4, 1, ?recv3(P2, P3, P4));
P2 -> insert(R4, 2, ?recv3(P1, P3, P4));
P3 -> insert(R4, 3, ?recv3(P1, P2, P4));
- P4 -> insert(R4, 4, ?recv3(P1, P2, P3))
+ P4 -> insert(R4, 4, ?recv3(P1, P2, P3));
+ V -> suite:match_failure([V], [P1, P2, P3, P4])
end
end)()).
@@ -51,7 +56,8 @@
P2 -> insert(R5, 2, ?recv4(P1, P3, P4, P5));
P3 -> insert(R5, 3, ?recv4(P1, P2, P4, P5));
P4 -> insert(R5, 4, ?recv4(P1, P2, P3, P5));
- P5 -> insert(R5, 5, ?recv4(P1, P2, P3, P4))
+ P5 -> insert(R5, 5, ?recv4(P1, P2, P3, P4));
+ V -> suite:match_failure([V], [P1, P2, P3, P4, P5])
end
end)()).