aboutsummaryrefslogtreecommitdiffstats
path: root/lib/test_server
diff options
context:
space:
mode:
authorPeter Andersson <[email protected]>2011-11-08 08:55:08 +0100
committerPeter Andersson <[email protected]>2011-11-13 23:18:51 +0100
commit2cacf6885cafa276985324924a038618b0bb10fd (patch)
tree98eb3f6d2486954227ce2937677aa9823e67daa1 /lib/test_server
parentdd2f23d718f079afb12b8d0b9d288428fb0ad49d (diff)
downloadotp-2cacf6885cafa276985324924a038618b0bb10fd.tar.gz
otp-2cacf6885cafa276985324924a038618b0bb10fd.tar.bz2
otp-2cacf6885cafa276985324924a038618b0bb10fd.zip
Add CSS stylesheet for the text and tables in Common Test and Test Server
Also make general improvements of presentation of results. OTP-9706
Diffstat (limited to 'lib/test_server')
-rw-r--r--lib/test_server/src/erl2html2.erl49
-rw-r--r--lib/test_server/src/test_server.erl2
-rw-r--r--lib/test_server/src/test_server_ctrl.erl234
3 files changed, 188 insertions, 97 deletions
diff --git a/lib/test_server/src/erl2html2.erl b/lib/test_server/src/erl2html2.erl
index c94d4627f9..0520f05df7 100644
--- a/lib/test_server/src/erl2html2.erl
+++ b/lib/test_server/src/erl2html2.erl
@@ -32,32 +32,34 @@
%--------------------------------------------------------------------
-module(erl2html2).
--export([convert/2]).
+-export([convert/2, convert/3]).
convert([], _Dest) -> % Fake clause.
ok;
convert(File, Dest) ->
+ %% The generated code uses the BGCOLOR attribute in the
+ %% BODY tag, which wasn't valid until HTML 3.2. Also,
+ %% good HTML should either override all colour attributes
+ %% or none of them -- *never* just a few.
+ %%
+ %% FIXME: The colours should *really* be set with
+ %% stylesheets...
+ Header = ["<!DOCTYPE HTML PUBLIC "
+ "\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
+ "<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\n"
+ "<html>\n"
+ "<head><title>", File, "</title></head>\n\n"
+ "<body bgcolor=\"white\" text=\"black\""
+ " link=\"blue\" vlink=\"purple\" alink=\"red\">\n"],
+ convert(File, Dest, Header).
+
+convert(File, Dest, Header) ->
case file:read_file(File) of
{ok, Bin} ->
Code=binary_to_list(Bin),
statistics(runtime),
- %% The generated code uses the BGCOLOR attribute in the
- %% BODY tag, which wasn't valid until HTML 3.2. Also,
- %% good HTML should either override all colour attributes
- %% or none of them -- *never* just a few.
- %%
- %% FIXME: The colours should *really* be set with
- %% stylesheets...
- Html0
- = ["<!DOCTYPE HTML PUBLIC "
- "\"-//W3C//DTD HTML 3.2 Final//EN\">\n"
- "<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\n"
- "<html>\n"
- "<head><title>", File, "</title></head>\n\n"
- "<body bgcolor=\"white\" text=\"black\""
- " link=\"blue\" vlink=\"purple\" alink=\"red\">\n"],
{Html1, Lines} = root(Code, [], 1),
- Html = [Html0,
+ Html = [Header,
"<pre>\n", Html1, "</pre>\n",
footer(Lines),"</body>\n</html>\n"],
file:write_file(Dest, Html);
@@ -174,9 +176,10 @@ linenum(Line) ->
[A,Pred,integer_to_list(Line),":"].
footer(Lines) ->
- {_, Time} = statistics(runtime),
-% io:format("Converted ~p lines in ~.2f Seconds.~n",
-% [Lines, Time/1000]),
- S = "<i>The transformation of this file (~p lines) took ~.2f seconds</i>",
- F = lists:flatten(io_lib:format(S, [Lines, Time/1000])),
- ["<hr size=1>",F,"<br>\n"].
+ "".
+%% {_, Time} = statistics(runtime),
+%% io:format("Converted ~p lines in ~.2f Seconds.~n",
+%% [Lines, Time/1000]),
+%% S = "<i>The transformation of this file (~p lines) took ~.2f seconds</i>",
+%% F = lists:flatten(io_lib:format(S, [Lines, Time/1000])),
+%% ["<hr size=1>",F,"<br>\n"].
diff --git a/lib/test_server/src/test_server.erl b/lib/test_server/src/test_server.erl
index 49f97686a0..0026b95872 100644
--- a/lib/test_server/src/test_server.erl
+++ b/lib/test_server/src/test_server.erl
@@ -1525,7 +1525,7 @@ get_loc(Pid) ->
get_mf(MFs) ->
get_mf(MFs, {undefined,undefined}).
-get_mf([MF|MFs], Found) when is_tuple(MF) ->
+get_mf([MF|MFs], _Found) when is_tuple(MF) ->
ModFunc = {Mod,_} = case MF of
{M,F,_} -> {M,F};
MF -> MF
diff --git a/lib/test_server/src/test_server_ctrl.erl b/lib/test_server/src/test_server_ctrl.erl
index 4fad86d16d..49cce9c429 100644
--- a/lib/test_server/src/test_server_ctrl.erl
+++ b/lib/test_server/src/test_server_ctrl.erl
@@ -1692,60 +1692,83 @@ do_test_cases(TopCases, SkipCases,
[print_if_known(N, {", ~w test cases",[N]},
{" (with repeated test cases)",[]})]),
Test = get(test_server_name),
+ TestName = if is_list(Test) ->
+ lists:flatten(io_lib:format("~s", [Test]));
+ true ->
+ lists:flatten(io_lib:format("~p", [Test]))
+ end,
+
test_server_sup:framework_call(report, [tests_start,{Test,N}]),
- Header =
- case test_server_sup:framework_call(overview_html_header, [Test], "") of
- "" ->
- TestName = lists:flatten(io_lib:format("~p", [Test])),
- ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n",
- "<!-- autogenerated by '", atom_to_list(?MODULE), "'. -->\n",
- "<html>\n",
- "<head><title>Test ", TestName, " results</title>\n",
- "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n",
- "</head>\n",
- "<body bgcolor=\"white\" text=\"black\" ",
- "link=\"blue\" vlink=\"purple\" alink=\"red\">",
- "<h2>Results from test ", TestName, "</h2>\n"];
- Html ->
- ["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n",
- "<!-- autogenerated by '", atom_to_list(?MODULE), "'. -->\n" | Html]
+ {Header,Footer} =
+ case test_server_sup:framework_call(get_html_wrapper,
+ [Test,true], "") of
+ Empty when (Empty == "") ; (element(2,Empty) == "") ->
+ put(basic_html, true),
+ {["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n",
+ "<!-- autogenerated by '", atom_to_list(?MODULE), "'. -->\n",
+ "<html>\n",
+ "<head><title>Test ", TestName, " results</title>\n",
+ "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n",
+ "</head>\n",
+ "<body bgcolor=\"white\" text=\"black\" ",
+ "link=\"blue\" vlink=\"purple\" alink=\"red\">",
+ "<h2>Results for test ", TestName, "</h2>\n"],
+ "\n</body>\n</html>\n"};
+ {basic_html,Html0,Html1} ->
+ put(basic_html, true),
+ {Html0++["<h1>Results for <i>",TestName,"</i></h1>\n"],
+ Html1};
+ {xhtml,Html0,Html1} ->
+ put(basic_html, false),
+ {Html0++["<h1>Results for <i>",TestName,"</i></h1>\n"],
+ Html1}
end,
- print(html, Header, []),
- print_timestamp(html, "Test started at "),
- print(html, "<p>Host:<br>\n"),
+ print(html, Header),
+
+ print(html, xhtml("<p>", "<h4>")),
+ print_timestamp(html, "Test started at "),
+ print(html, xhtml("</p>", "</h4>")),
+
+ print(html, xhtml("<p>HOST:<br>\n", "<p>HOST:<br />\n")),
print_who(test_server_sup:hoststr(), test_server_sup:get_username()),
- print(html, "<br>Used Erlang ~s in <tt>~s</tt>.\n",
+ print(html, xhtml("<br>Used Erlang v~s in <tt>~s</tt></p>\n",
+ "<br />Used Erlang v~s in \"~s\"</p>\n"),
[erlang:system_info(version), code:root_dir()]),
-
+
if FwMod == ?MODULE ->
- print(html, "<p>Target:<br>\n"),
+ print(html, xhtml("<p>TARGET:<br>\n", "<p>TARGET:<br />\n")),
print_who(TI#target_info.host, TI#target_info.username),
- print(html, "<br>Used Erlang ~s in <tt>~s</tt>.\n",
+ print(html, xhtml("<br>Used Erlang v~s in <tt>~s</tt></p>\n",
+ "<br />Used Erlang v~s in \"~s\"</p>\n"),
[TI#target_info.version, TI#target_info.root_dir]);
- true ->
+ true ->
case test_server_sup:framework_call(target_info, []) of
TargetInfo when is_list(TargetInfo),
length(TargetInfo) > 0 ->
- print(html, "<p>Target:<br>\n"),
- print(html, "~s\n", [TargetInfo]);
+ print(html, xhtml("<p>TARGET:<br>\n", "<p>TARGET:<br />\n")),
+ print(html, "~s</p>\n", [TargetInfo]);
_ ->
ok
end
end,
-
+
print(html,
- "<p><a href=\"~s\">Full textual log</a>\n"
- "<br><a href=\"~s\">Coverage log</a>\n",
+ "<ul>\n"
+ "<li><a href=\"~s\">Full textual log</a></li>\n"
+ "<li><a href=\"~s\">Coverage log</a></li>\n</ul>\n",
[?suitelog_name,?coverlog_name]),
- print(html,"<p>~s"
- "<p>\n"
- "<table bgcolor=\"white\" border=\"3\" cellpadding=\"5\">"
- "<tr><th>Num</th><th>Module</th><th>Case</th><th>Log</th>"
- "<th>Time</th><th>Result</th><th>Comment</th></tr>\n",
- [print_if_known(N, {"Suite contains ~p test cases.\n",[N]},
+ print(html,
+ "<p>~s</p>\n" ++
+ xhtml("<table bgcolor=\"white\" border=\"3\" cellpadding=\"5\">",
+ "<table>") ++
+ "<tr><th>Num</th><th>Module</th><th>Case</th><th>Log</th>"
+ "<th>Time</th><th>Result</th><th>Comment</th></tr>\n",
+ [print_if_known(N, {"Executing ~p test cases...\n",[N]},
{"",[]})]),
+ print(html, xhtml("<br>", "<br />")),
+
print(major, "=cases ~p", [get(test_server_cases)]),
print(major, "=user ~s", [TI#target_info.username]),
print(major, "=host ~s", [TI#target_info.host]),
@@ -1764,6 +1787,9 @@ do_test_cases(TopCases, SkipCases,
print(major, "=otp_release ~s", [TI#target_info.otp_release]),
print(major, "=started ~s",
[lists:flatten(timestamp_get(""))]),
+
+ put(test_server_html_footer, Footer),
+
run_test_cases(TestSpec, Config, TimetrapData)
end;
@@ -1881,16 +1907,31 @@ start_minor_log_file1(Mod, Func, LogDir, AbsName) ->
{ok,Fd} = file:open(AbsName, [write]),
Lev = get(test_server_minor_level)+1000, %% far down in the minor levels
put(test_server_minor_fd, Fd),
- io:fwrite(Fd,
- "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n"
- "<!-- autogenerated by '"++atom_to_list(?MODULE)++"'. -->\n"
- "<html>\n"
- "<head><title>"++cast_to_list(Mod)++"</title>\n"
- "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n"
- "</head>\n"
- "<body bgcolor=\"white\" text=\"black\""
- " link=\"blue\" vlink=\"purple\" alink=\"red\">\n",
- []),
+
+ TestName = io_lib:format("~p:~p", [Mod,Func]),
+ {Header,Footer} =
+ case test_server_sup:framework_call(get_html_wrapper,
+ [TestName,false], "") of
+ Empty when (Empty == "") ; (element(2,Empty) == "") ->
+ put(basic_html, true),
+ {["<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2 Final//EN\">\n",
+ "<!-- autogenerated by '", atom_to_list(?MODULE), "'. -->\n",
+ "<html>\n",
+ "<head><title>Test ", TestName, "</title>\n",
+ "<meta http-equiv=\"cache-control\" content=\"no-cache\">\n",
+ "</head>\n",
+ "<body bgcolor=\"white\" text=\"black\" ",
+ "link=\"blue\" vlink=\"purple\" alink=\"red\">\n"],
+ "\n</body>\n</html>\n"};
+ {basic_html,Html0,Html1} ->
+ put(basic_html, true),
+ {Html0,Html1};
+ {xhtml,Html0,Html1} ->
+ put(basic_html, false),
+ {Html0,Html1}
+ end,
+ put(test_server_minor_footer, Footer),
+ io:fwrite(Fd, Header, []),
SrcListing = downcase(cast_to_list(Mod)) ++ ?src_listing_ext,
case {filelib:is_file(filename:join(LogDir, SrcListing)),
@@ -1913,7 +1954,8 @@ start_minor_log_file1(Mod, Func, LogDir, AbsName) ->
stop_minor_log_file() ->
Fd = get(test_server_minor_fd),
- io:fwrite(Fd, "</pre>\n</body>\n</html>\n", []),
+ Footer = get(test_server_minor_footer),
+ io:fwrite(Fd, "</pre>\n" ++ Footer, []),
file:close(Fd),
put(test_server_minor_fd, undefined).
@@ -1992,12 +2034,27 @@ html_convert_modules([]) -> ok.
%% Convert source code to HTML if possible and needed.
html_possibly_convert(Src, SrcInfo, Dest) ->
case file:read_file_info(Dest) of
- {error,_Reason} -> % no dest file
- erl2html2:convert(Src, Dest);
- {ok,DestInfo} when DestInfo#file_info.mtime < SrcInfo#file_info.mtime ->
- erl2html2:convert(Src, Dest);
- {ok,_DestInfo} ->
- ok % dest file up to date
+ {ok,DestInfo} when DestInfo#file_info.mtime >= SrcInfo#file_info.mtime ->
+ ok; % dest file up to date
+ _ ->
+ Header =
+ case test_server_sup:framework_call(get_html_header,
+ [Src,false], "") of
+ Empty when (Empty == "") ; (element(2,Empty) == "") ->
+ ["<!DOCTYPE HTML PUBLIC",
+ "\"-//W3C//DTD HTML 3.2 Final//EN\">\n",
+ "<!-- autogenerated by 'er2html2' -->\n",
+ "<html>\n",
+ "<head><title>Test ", Src, "</title>\n",
+ "<meta http-equiv=\"cache-control\" ",
+ "content=\"no-cache\">\n",
+ "</head>\n",
+ "<body bgcolor=\"white\" text=\"black\" ",
+ "link=\"blue\" vlink=\"purple\" alink=\"red\">\n"];
+ {_,Html,_} ->
+ Html
+ end,
+ erl2html2:convert(Src, Dest, Header)
end.
%% Copy all HTML files in InDir to OutDir.
@@ -3163,9 +3220,9 @@ skip_case1(Type, CaseNum, Mod, Func, Comment, Mode) ->
print(major, "=started ~s", [lists:flatten(timestamp_get(""))]),
print(major, "=result skipped: ~s", [Comment1]),
print(2,"*** Skipping test case #~w ~p ***", [CaseNum,{Mod,Func}]),
+ TR = xhtml("<tr valign=\"top\">", ["<tr class=\"",odd_or_even(),"\">"]),
print(html,
- "<tr valign=top>"
- "<td>" ++ Col0 ++ "~s" ++ Col1 ++ "</td>"
+ TR ++ "<td>" ++ Col0 ++ "~s" ++ Col1 ++ "</td>"
"<td>" ++ Col0 ++ "~p" ++ Col1 ++ "</td>"
"<td>" ++ Col0 ++ "~p" ++ Col1 ++ "</td>"
"<td>" ++ Col0 ++ "< >" ++ Col1 ++ "</td>"
@@ -3567,11 +3624,12 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit, Where,
print_props((RunInit==skip_init), get_props(Mode)),
print(major, "=started ~s", [lists:flatten(timestamp_get(""))]),
{{Col0,Col1},Style} = get_font_style((RunInit==run_init), Mode),
- print(html, "<tr valign=top><td>" ++ Col0 ++ "~s" ++ Col1 ++ "</td>"
- "<td>" ++ Col0 ++ "~p" ++ Col1 ++ "</td>"
- "<td><a href=\"~s\">~p</a></td>"
- "<td><a href=\"~s#top\"><</a> <a href=\"~s#end\">></a></td>",
- [num2str(Num),Mod,MinorBase,Func,MinorBase,MinorBase]),
+ TR = xhtml("<tr valign=\"top\">", ["<tr class=\"",odd_or_even(),"\">"]),
+ print(html, TR ++ "<td>" ++ Col0 ++ "~s" ++ Col1 ++ "</td>"
+ "<td>" ++ Col0 ++ "~p" ++ Col1 ++ "</td>"
+ "<td><a href=\"~s\">~p</a></td>"
+ "<td><a href=\"~s#top\"><</a> <a href=\"~s#end\">></a></td>",
+ [num2str(Num),Mod,MinorBase,Func,MinorBase,MinorBase]),
do_if_parallel(Main, ok, fun erlang:yield/0),
%% run the test case
@@ -3857,7 +3915,7 @@ progress(skip, CaseNum, Mod, Func, Loc, Reason, Time,
end,
Comment1 = case Comment of
"" -> "";
- _ -> "<br>(" ++ to_string(Comment) ++ ")"
+ _ -> xhtml("<br>(","<br />(") ++ to_string(Comment) ++ ")"
end,
print(html,
"<td>" ++ St0 ++ "~.3fs" ++ St1 ++ "</td>"
@@ -3882,8 +3940,8 @@ progress(failed, CaseNum, Mod, Func, Loc, timetrap_timeout, T,
Comment =
case Comment0 of
"" -> "<font color=\"red\">" ++ ErrorReason ++ "</font>";
- _ -> "<font color=\"red\">" ++ ErrorReason ++ "</font><br>" ++
- to_string(Comment0)
+ _ -> "<font color=\"red\">" ++ ErrorReason ++
+ xhtml("</font><br>","</font><br />") ++ to_string(Comment0)
end,
print(html,
"<td>" ++ St0 ++ "~.3fs" ++ St1 ++ "</td>"
@@ -3908,8 +3966,8 @@ progress(failed, CaseNum, Mod, Func, Loc, {testcase_aborted,Reason}, _T,
Comment =
case Comment0 of
"" -> "<font color=\"red\">" ++ ErrorReason ++ "</font>";
- _ -> "<font color=\"red\">" ++ ErrorReason ++ "</font><br>" ++
- to_string(Comment0)
+ _ -> "<font color=\"red\">" ++ ErrorReason ++
+ xhtml("</font><br>","</font><br />") ++ to_string(Comment0)
end,
print(html,
"<td>" ++ St0 ++ "died" ++ St1 ++ "</td>"
@@ -3943,7 +4001,8 @@ progress(failed, CaseNum, Mod, Func, unknown, Reason, Time,
Comment =
case Comment0 of
"" -> "<font color=\"red\">" ++ ErrorReason2 ++ "</font>";
- _ -> "<font color=\"red\">" ++ ErrorReason2 ++ "</font><br>" ++
+ _ -> "<font color=\"red\">" ++ ErrorReason2 ++
+ xhtml("</font><br>","</font><br />") ++
to_string(Comment0)
end,
print(html,
@@ -3953,7 +4012,7 @@ progress(failed, CaseNum, Mod, Func, unknown, Reason, Time,
[TimeStr,Comment]),
print(minor, "=== location ~s", [unknown]),
{FStr,FormattedReason} = format_exception(Reason),
- print(minor, "=== reason = "++FStr, [FormattedReason]),
+ print(minor, "=== reason = " ++ FStr, [FormattedReason]),
failed;
progress(failed, CaseNum, Mod, Func, Loc, Reason, Time,
@@ -3969,7 +4028,7 @@ progress(failed, CaseNum, Mod, Func, Loc, Reason, Time,
Comment =
case Comment0 of
"" -> "";
- _ -> "<br>" ++ to_string(Comment0)
+ _ -> xhtml("<br>","<br />") ++ to_string(Comment0)
end,
FormatLastLoc = test_server_sup:format_loc(get_last_loc(Loc)),
print(html,
@@ -3980,7 +4039,7 @@ progress(failed, CaseNum, Mod, Func, Loc, Reason, Time,
FormatLoc = test_server_sup:format_loc(Loc),
print(minor, "=== location ~s", [FormatLoc]),
{FStr,FormattedReason} = format_exception(Reason),
- print(minor, "=== reason = "++FStr, [FormattedReason]),
+ print(minor, "=== reason = " ++ FStr, [FormattedReason]),
failed;
progress(ok, _CaseNum, Mod, Func, _Loc, RetVal, Time,
@@ -3999,7 +4058,7 @@ progress(ok, _CaseNum, Mod, Func, _Loc, RetVal, Time,
_ ->
print(major, "=result ok", []),
case Comment0 of
- "" -> "";
+ "" -> "<td></td>";
_ -> "<td>" ++ to_string(Comment0) ++ "</td>"
end
end,
@@ -4349,7 +4408,13 @@ output({html,Msg}, _Sender) ->
%% We are writing to a seekable file. Finalise so
%% we get complete valid (and viewable) HTML code.
%% Then rewind to overwrite the finalising code.
- io:put_chars(Fd, "\n</table>\n</body>\n</html>\n"),
+ io:put_chars(Fd, "\n</table>\n"),
+ case get(test_server_html_footer) of
+ undefined ->
+ io:put_chars(Fd, "</body>\n</html>\n");
+ Footer ->
+ io:put_chars(Fd, Footer)
+ end,
file:position(Fd, Pos);
{error, epipe} ->
%% The file is not seekable. We cannot erase what
@@ -4394,6 +4459,28 @@ output_to_fd(Fd, Msg, _Sender) ->
end.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% xhtml(BasicHtml, XHtml) -> BasicHtml | XHtml
+%%
+xhtml(HTML, XHTML) ->
+ case get(basic_html) of
+ true -> HTML;
+ _ -> XHTML
+ end.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%% odd_or_even() -> "odd" | "even"
+%%
+odd_or_even() ->
+ case get(odd_or_even) of
+ even ->
+ put(odd_or_even, odd),
+ "even";
+ _ ->
+ put(odd_or_even, even),
+ "odd"
+ end.
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% timestamp_filename_get(Leader) -> string()
%% Leader = string()
%%
@@ -5499,9 +5586,10 @@ write_default_cross_coverlog(TestDir) ->
file:open(filename:join(TestDir,?cross_coverlog_name), [write]),
write_coverlog_header(CrossCoverLog),
io:fwrite(CrossCoverLog,
- "No cross cover modules exist for this application,<br>"
- "or cross cover analysis is not completed.\n"
- "</body></html>\n", []),
+ ["No cross cover modules exist for this application,",
+ xhtml("<br>","<br />"),
+ "or cross cover analysis is not completed.\n"
+ "</body></html>\n"], []),
file:close(CrossCoverLog).
write_cover_result_table(CoverLog,Coverage) ->