aboutsummaryrefslogtreecommitdiffstats
path: root/lib/common_test/src
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2016-03-09 14:11:30 +0100
committerPeter Andersson <[email protected]>2016-03-09 17:12:49 +0100
commit52cee865fd9e5b4a1371c82075375a92b8f03fbe (patch)
tree7e1e8391e914eb093eab32fd6645e4d8f89e3101 /lib/common_test/src
parentfb44a4de532ae97b3424078577dee7370078dea0 (diff)
downloadotp-52cee865fd9e5b4a1371c82075375a92b8f03fbe.tar.gz
otp-52cee865fd9e5b4a1371c82075375a92b8f03fbe.tar.bz2
otp-52cee865fd9e5b4a1371c82075375a92b8f03fbe.zip
Fix minor issues with escaping characters
OTP-13003
Diffstat (limited to 'lib/common_test/src')
-rw-r--r--lib/common_test/src/ct.erl2
-rw-r--r--lib/common_test/src/ct_conn_log_h.erl46
-rw-r--r--lib/common_test/src/ct_logs.erl14
-rw-r--r--lib/common_test/src/cth_conn_log.erl2
4 files changed, 40 insertions, 24 deletions
diff --git a/lib/common_test/src/ct.erl b/lib/common_test/src/ct.erl
index 1c1b46c2af..538be514d6 100644
--- a/lib/common_test/src/ct.erl
+++ b/lib/common_test/src/ct.erl
@@ -591,7 +591,7 @@ log(X1,X2,X3,X4) ->
%%% Format = string()
%%% Args = list()
%%% Opts = [Opt]
-%%% Opt = esc_chars
+%%% Opt = esc_chars | no_css
%%%
%%% @doc Printout from a test case to the log file.
%%%
diff --git a/lib/common_test/src/ct_conn_log_h.erl b/lib/common_test/src/ct_conn_log_h.erl
index 93f358462d..034906a3ba 100644
--- a/lib/common_test/src/ct_conn_log_h.erl
+++ b/lib/common_test/src/ct_conn_log_h.erl
@@ -105,52 +105,62 @@ terminate(_,#state{logs=Logs}) ->
%%% Writing reports
write_report(_Time,#conn_log{header=false,module=ConnMod}=Info,Data,GL,State) ->
case get_log(Info,GL,State) of
- {silent,_} ->
+ {silent,_,_} ->
ok;
- {LogType,Fd} ->
- io:format(Fd,"~n~ts",[format_data(ConnMod,LogType,Data)])
+ {LogType,Dest,Fd} ->
+ Str = if LogType == html, Dest == gl -> ["$tc_html","~n~ts"];
+ true -> "~n~ts"
+ end,
+ io:format(Fd,Str,[format_data(ConnMod,LogType,Data)])
end;
write_report(Time,#conn_log{module=ConnMod}=Info,Data,GL,State) ->
case get_log(Info,GL,State) of
- {silent,_} ->
+ {silent,_,_} ->
ok;
- {LogType,Fd} ->
+ {LogType,Dest,Fd} ->
case format_data(ConnMod,LogType,Data) of
[] when Info#conn_log.action==send; Info#conn_log.action==recv ->
ok;
FormattedData ->
- io:format(Fd,"~n~ts~ts~ts",[format_head(ConnMod,LogType,Time),
- format_title(LogType,Info),
- FormattedData])
+ Str = if LogType == html, Dest == gl ->
+ ["$tc_html","~n~ts~ts~ts"];
+ true ->
+ "~n~ts~ts~ts"
+ end,
+ io:format(Fd,Str,[format_head(ConnMod,LogType,Time),
+ format_title(LogType,Info),
+ FormattedData])
end
end.
write_error(Time,#conn_log{module=ConnMod}=Info,Report,GL,State) ->
case get_log(Info,GL,State) of
- {LogType,_} when LogType==html; LogType==silent ->
+ {LogType,_,_} when LogType==html; LogType==silent ->
%% The error will anyway be written in the html log by the
%% sasl error handler, so don't write it again.
ok;
- {LogType,Fd} ->
- io:format(Fd,"~n~ts~ts~ts",
- [format_head(ConnMod,LogType,Time," ERROR"),
- format_title(LogType,Info),
- format_error(LogType,Report)])
+ {LogType,Dest,Fd} ->
+ Str = if LogType == html, Dest == gl -> ["$tc_html","~n~ts~ts~ts"];
+ true -> "~n~ts~ts~ts"
+ end,
+ io:format(Fd,Str,[format_head(ConnMod,LogType,Time," ERROR"),
+ format_title(LogType,Info),
+ format_error(LogType,Report)])
end.
get_log(Info,GL,State) ->
case proplists:get_value(GL,State#state.logs) of
undefined ->
- {html,State#state.default_gl};
+ {html,gl,State#state.default_gl};
ConnLogs ->
case proplists:get_value(Info#conn_log.module,ConnLogs) of
{html,_} ->
- {html,GL};
+ {html,gl,GL};
{LogType,Fds} ->
- {LogType,get_fd(Info,Fds)};
+ {LogType,file,get_fd(Info,Fds)};
undefined ->
- {html,GL}
+ {html,gl,GL}
end
end.
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index e3f995ad3f..4920383f39 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -432,10 +432,16 @@ tc_log(Category,Importance,Format,Args,Opts) ->
%%% stuff directly from a testcase (i.e. not from within the CT
%%% framework).</p>
tc_log(Category,Importance,Printer,Format,Args,Opts) ->
- cast({log,sync,self(),group_leader(),Category,Importance,
- [{hd,div_header(Category,Printer),[]},
- {Format,Args},
- {ft,div_footer(),[]}],
+ Data =
+ case lists:member(no_css, Opts) of
+ true ->
+ [{Format,Args}];
+ false ->
+ [{hd,div_header(Category,Printer),[]},
+ {Format,Args},
+ {ft,div_footer(),[]}]
+ end,
+ cast({log,sync,self(),group_leader(),Category,Importance,Data,
lists:member(esc_chars, Opts)}),
ok.
diff --git a/lib/common_test/src/cth_conn_log.erl b/lib/common_test/src/cth_conn_log.erl
index 9b3dc0b5f1..954b4239af 100644
--- a/lib/common_test/src/cth_conn_log.erl
+++ b/lib/common_test/src/cth_conn_log.erl
@@ -132,7 +132,7 @@ pre_init_per_testcase(TestCase,Config,CthState) ->
[S,ct_logs:uri(L),filename:basename(L)])
|| {S,L} <- Ls] ++
"</table>",
- io:format(Str,[]),
+ ct:log(Str,[],[no_css]),
{ConnMod,{LogType,Ls}};
_ ->
{ConnMod,{LogType,[]}}