aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src/ct_run.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2017-05-11 12:51:04 +0200
committerGitHub <[email protected]>2017-05-11 12:51:04 +0200
commitc3a81d86c0ad0245cd47ff17aee70dc816c07e39 (patch)
treef21ea993bd379ebb960bc896c15532aae9e00f09 /lib/common_test/src/ct_run.erl
parent5aa7180ae0ad7a34d1903003cbcd4a7d5cc61858 (diff)
parent5d7e12f4d037f74602029850bbd29e38c3732b48 (diff)
downloadotp-c3a81d86c0ad0245cd47ff17aee70dc816c07e39.tar.gz
otp-c3a81d86c0ad0245cd47ff17aee70dc816c07e39.tar.bz2
otp-c3a81d86c0ad0245cd47ff17aee70dc816c07e39.zip
Merge pull request #1449 from bjorng/bjorn/future-proof-exceptions
Make calls to get_stacktrace/0 future-proof OTP-14400
Diffstat (limited to 'lib/common_test/src/ct_run.erl')
-rw-r--r--lib/common_test/src/ct_run.erl26
1 files changed, 17 insertions, 9 deletions
diff --git a/lib/common_test/src/ct_run.erl b/lib/common_test/src/ct_run.erl
index bbace18a28..ce30babc0d 100644
--- a/lib/common_test/src/ct_run.erl
+++ b/lib/common_test/src/ct_run.erl
@@ -436,13 +436,17 @@ script_start2(Opts = #opts{vts = undefined,
Specs1 = get_start_opt(join_specs, [Specs], Specs, Args),
%% using testspec as input for test
Relaxed = get_start_opt(allow_user_terms, true, false, Args),
- case catch ct_testspec:collect_tests_from_file(Specs1, Relaxed) of
- {E,Reason} when E == error ; E == 'EXIT' ->
+ try ct_testspec:collect_tests_from_file(Specs1, Relaxed) of
+ TestSpecData ->
+ execute_all_specs(TestSpecData, Opts, Args, [])
+ catch
+ throw:{error,Reason} ->
StackTrace = erlang:get_stacktrace(),
{error,{invalid_testspec,{Reason,StackTrace}}};
- TestSpecData ->
- execute_all_specs(TestSpecData, Opts, Args, [])
- end;
+ _:Reason ->
+ StackTrace = erlang:get_stacktrace(),
+ {error,{invalid_testspec,{Reason,StackTrace}}}
+ end;
[] ->
{error,no_testspec_specified};
_ -> % no testspec used
@@ -1198,12 +1202,16 @@ run_spec_file(Relaxed,
end,
AbsSpecs = lists:map(fun(SF) -> ?abs(SF) end, Specs1),
AbsSpecs1 = get_start_opt(join_specs, [AbsSpecs], AbsSpecs, StartOpts),
- case catch ct_testspec:collect_tests_from_file(AbsSpecs1, Relaxed) of
- {Error,CTReason} when Error == error ; Error == 'EXIT' ->
- StackTrace = erlang:get_stacktrace(),
- exit({error,{invalid_testspec,{CTReason,StackTrace}}});
+ try ct_testspec:collect_tests_from_file(AbsSpecs1, Relaxed) of
TestSpecData ->
run_all_specs(TestSpecData, Opts, StartOpts, [])
+ catch
+ throw:{error,CTReason} ->
+ StackTrace = erlang:get_stacktrace(),
+ exit({error,{invalid_testspec,{CTReason,StackTrace}}});
+ _:CTReason ->
+ StackTrace = erlang:get_stacktrace(),
+ exit({error,{invalid_testspec,{CTReason,StackTrace}}})
end.
run_all_specs([], _, _, TotResult) ->