diff options
author | Erlang/OTP <[email protected]> | 2015-05-06 10:46:17 +0200 |
---|---|---|
committer | Erlang/OTP <[email protected]> | 2015-05-06 10:46:17 +0200 |
commit | f1a129d3158d378fbf465ab42f69a01d30711904 (patch) | |
tree | dbaa98ef770a0653d5aeb9033acd4abb58cb5db1 /lib/test_server/src/test_server.erl | |
parent | edd79759508320ca529a05073c84465ab810811e (diff) | |
parent | bcbee3d20d21e3f4c5bb29de96fddf07302922a6 (diff) | |
download | otp-f1a129d3158d378fbf465ab42f69a01d30711904.tar.gz otp-f1a129d3158d378fbf465ab42f69a01d30711904.tar.bz2 otp-f1a129d3158d378fbf465ab42f69a01d30711904.zip |
Merge branch 'peppe/common_test/timetrap_line.maint' into maint-17
* peppe/common_test/timetrap_line.maint:
Fix problem with line number not always showing in log
Diffstat (limited to 'lib/test_server/src/test_server.erl')
-rw-r--r-- | lib/test_server/src/test_server.erl | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl index 8d91778cbb..1c3352550b 100644 --- a/lib/test_server/src/test_server.erl +++ b/lib/test_server/src/test_server.erl @@ -1355,12 +1355,30 @@ get_loc(Pid) -> Stk = [rewrite_loc_item(Loc) || Loc <- Stk0], case get(test_server_loc) of [{Suite,Case}] -> - %% location info unknown, check if {Suite,Case,Line} - %% is available in stacktrace. and if so, use stacktrace - %% instead of current test_server_loc + %% Location info unknown, check if {Suite,Case,Line} + %% is available in stacktrace and if so, use stacktrace + %% instead of current test_server_loc. + %% If location is the last expression in a test case + %% function, the info is not available due to tail call + %% elimination. We need to check if the test case has been + %% called by ts_tc/3 and, if so, insert the test case info + %% at that position. case [match || {S,C,_L} <- Stk, S == Suite, C == Case] of - [match|_] -> put(test_server_loc, Stk); - _ -> ok + [match|_] -> + put(test_server_loc, Stk); + _ -> + {PreTC,PostTC} = + lists:splitwith(fun({test_server,ts_tc,_}) -> + false; + (_) -> + true + end, Stk), + if PostTC == [] -> + ok; + true -> + put(test_server_loc, + PreTC++[{Suite,Case,last_expr} | PostTC]) + end end; _ -> put(test_server_loc, Stk) @@ -1422,7 +1440,10 @@ lookup_config(Key,Config) -> undefined end. -%% timer:tc/3 +%% +%% IMPORTANT: get_loc/1 uses the name of this function when analysing +%% stack traces. If the name changes, get_loc/1 must be updated! +%% ts_tc(M, F, A) -> Before = erlang:now(), Result = try |