aboutsummaryrefslogtreecommitdiffstats
path: root/lib/mnesia/test/mnesia_test_lib.hrl
diff options
context:
space:
mode:
authorDan Gudmundsson <[email protected]>2014-04-03 13:43:38 +0200
committerDan Gudmundsson <[email protected]>2014-04-11 09:59:11 +0200
commitc9245f29ff5c5a59a58749cb3dceb2eaad4957e0 (patch)
tree498d6dd880a662e6c2c8389890ca3019aaaf67ce /lib/mnesia/test/mnesia_test_lib.hrl
parentbee0ea4125e8b47478b77904bee06f8f38bbab42 (diff)
downloadotp-c9245f29ff5c5a59a58749cb3dceb2eaad4957e0.tar.gz
otp-c9245f29ff5c5a59a58749cb3dceb2eaad4957e0.tar.bz2
otp-c9245f29ff5c5a59a58749cb3dceb2eaad4957e0.zip
mnesia: Improve tests
Need to re-raise the match macro if inside transaction
Diffstat (limited to 'lib/mnesia/test/mnesia_test_lib.hrl')
-rw-r--r--lib/mnesia/test/mnesia_test_lib.hrl35
1 files changed, 26 insertions, 9 deletions
diff --git a/lib/mnesia/test/mnesia_test_lib.hrl b/lib/mnesia/test/mnesia_test_lib.hrl
index 281634c239..94a195f01f 100644
--- a/lib/mnesia/test/mnesia_test_lib.hrl
+++ b/lib/mnesia/test/mnesia_test_lib.hrl
@@ -46,15 +46,32 @@
-define(match(ExpectedRes,Expr),
fun() ->
- AcTuAlReS = (catch (Expr)),
- case AcTuAlReS of
- ExpectedRes ->
- ?verbose("ok, ~n Result as expected:~p~n",[AcTuAlReS]),
- {success,AcTuAlReS};
- _ ->
- ?error("Not Matching Actual result was:~n ~p~n",
- [AcTuAlReS]),
- {fail,AcTuAlReS}
+ try Expr of
+ _AR_0 = ExpectedRes ->
+ ?verbose("ok, ~n Result as expected:~p~n",[_AR_0]),
+ {success,_AR_0};
+ _AR_0 ->
+ ?error("Not Matching Actual result was:~n ~p~n",[_AR_0]),
+ {fail,_AR_0}
+ catch
+ exit:{aborted, _ER_1} when
+ element(1, _ER_1) =:= node_not_running;
+ element(1, _ER_1) =:= bad_commit;
+ element(1, _ER_1) =:= cyclic ->
+ %% Need to re-raise these to restart transaction
+ erlang:raise(exit, {aborted, _ER_1}, erlang:get_stacktrace());
+ exit:_AR_1 ->
+ case fun(_AR_EXIT_) -> {'EXIT', _AR_EXIT_} end(_AR_1) of
+ _AR_2 = ExpectedRes ->
+ ?verbose("ok, ~n Result as expected:~p~n",[_AR_2]),
+ {success,_AR_2};
+ _AR_2 ->
+ ?error("Not Matching Actual result was:~n ~p~n", [_AR_2]),
+ {fail,_AR_2}
+ end;
+ _:_AR_1 ->
+ ?error("Not Matching Actual result was:~n ~p~n", [_AR_1]),
+ {fail,_AR_1}
end
end()).