From 2cacf6885cafa276985324924a038618b0bb10fd Mon Sep 17 00:00:00 2001 From: Peter Andersson Date: Tue, 8 Nov 2011 08:55:08 +0100 Subject: Add CSS stylesheet for the text and tables in Common Test and Test Server Also make general improvements of presentation of results. OTP-9706 --- lib/test_server/src/test_server_ctrl.erl | 234 +++++++++++++++++++++---------- 1 file changed, 161 insertions(+), 73 deletions(-) (limited to 'lib/test_server/src/test_server_ctrl.erl') 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])), - ["\n", - "\n", - "\n", - "Test ", TestName, " results\n", - "\n", - "\n", - "", - "

Results from test ", TestName, "

\n"]; - Html -> - ["\n", - "\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), + {["\n", + "\n", + "\n", + "Test ", TestName, " results\n", + "\n", + "\n", + "", + "

Results for test ", TestName, "

\n"], + "\n\n\n"}; + {basic_html,Html0,Html1} -> + put(basic_html, true), + {Html0++["

Results for ",TestName,"

\n"], + Html1}; + {xhtml,Html0,Html1} -> + put(basic_html, false), + {Html0++["

Results for ",TestName,"

\n"], + Html1} end, - print(html, Header, []), - print_timestamp(html, "Test started at "), - print(html, "

Host:
\n"), + print(html, Header), + + print(html, xhtml("

", "

")), + print_timestamp(html, "Test started at "), + print(html, xhtml("

", "

")), + + print(html, xhtml("

HOST:
\n", "

HOST:
\n")), print_who(test_server_sup:hoststr(), test_server_sup:get_username()), - print(html, "
Used Erlang ~s in ~s.\n", + print(html, xhtml("
Used Erlang v~s in ~s

\n", + "
Used Erlang v~s in \"~s\"

\n"), [erlang:system_info(version), code:root_dir()]), - + if FwMod == ?MODULE -> - print(html, "

Target:
\n"), + print(html, xhtml("

TARGET:
\n", "

TARGET:
\n")), print_who(TI#target_info.host, TI#target_info.username), - print(html, "
Used Erlang ~s in ~s.\n", + print(html, xhtml("
Used Erlang v~s in ~s

\n", + "
Used Erlang v~s in \"~s\"

\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, "

Target:
\n"), - print(html, "~s\n", [TargetInfo]); + print(html, xhtml("

TARGET:
\n", "

TARGET:
\n")), + print(html, "~s

\n", [TargetInfo]); _ -> ok end end, - + print(html, - "

Full textual log\n" - "
Coverage log\n", + "

\n", [?suitelog_name,?coverlog_name]), - print(html,"

~s" - "

\n" - "" - "" - "\n", - [print_if_known(N, {"Suite contains ~p test cases.\n",[N]}, + print(html, + "

~s

\n" ++ + xhtml("
NumModuleCaseLogTimeResultComment
", + "
") ++ + "" + "\n", + [print_if_known(N, {"Executing ~p test cases...\n",[N]}, {"",[]})]), + print(html, xhtml("
", "
")), + 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, - "\n" - "\n" - "\n" - ""++cast_to_list(Mod)++"\n" - "\n" - "\n" - "\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), + {["\n", + "\n", + "\n", + "Test ", TestName, "\n", + "\n", + "\n", + "\n"], + "\n\n\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, "\n\n\n", []), + Footer = get(test_server_minor_footer), + io:fwrite(Fd, "\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) == "") -> + ["\n", + "\n", + "\n", + "Test ", Src, "\n", + "\n", + "\n", + "\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("", [""]), print(html, - "" - "" + TR ++ "" "" "" "" @@ -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, "" - "" - "" - "", - [num2str(Num),Mod,MinorBase,Func,MinorBase,MinorBase]), + TR = xhtml("", [""]), + print(html, TR ++ "" + "" + "" + "", + [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 "" -> ""; - _ -> "
(" ++ to_string(Comment) ++ ")" + _ -> xhtml("
(","
(") ++ to_string(Comment) ++ ")" end, print(html, "" @@ -3882,8 +3940,8 @@ progress(failed, CaseNum, Mod, Func, Loc, timetrap_timeout, T, Comment = case Comment0 of "" -> "" ++ ErrorReason ++ ""; - _ -> "" ++ ErrorReason ++ "
" ++ - to_string(Comment0) + _ -> "" ++ ErrorReason ++ + xhtml("
","
") ++ to_string(Comment0) end, print(html, "" @@ -3908,8 +3966,8 @@ progress(failed, CaseNum, Mod, Func, Loc, {testcase_aborted,Reason}, _T, Comment = case Comment0 of "" -> "" ++ ErrorReason ++ ""; - _ -> "" ++ ErrorReason ++ "
" ++ - to_string(Comment0) + _ -> "" ++ ErrorReason ++ + xhtml("
","
") ++ to_string(Comment0) end, print(html, "" @@ -3943,7 +4001,8 @@ progress(failed, CaseNum, Mod, Func, unknown, Reason, Time, Comment = case Comment0 of "" -> "" ++ ErrorReason2 ++ ""; - _ -> "" ++ ErrorReason2 ++ "
" ++ + _ -> "" ++ ErrorReason2 ++ + xhtml("
","
") ++ 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 "" -> ""; - _ -> "
" ++ to_string(Comment0) + _ -> xhtml("
","
") ++ 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 - "" -> ""; + "" -> ""; _ -> "" 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
NumModuleCaseLogTimeResultComment
" ++ Col0 ++ "~s" ++ Col1 ++ "" ++ Col0 ++ "~s" ++ Col1 ++ "" ++ Col0 ++ "~p" ++ Col1 ++ "" ++ Col0 ++ "~p" ++ Col1 ++ "" ++ Col0 ++ "< >" ++ Col1 ++ "
" ++ Col0 ++ "~s" ++ Col1 ++ "" ++ Col0 ++ "~p" ++ Col1 ++ "~p< >
" ++ Col0 ++ "~s" ++ Col1 ++ "" ++ Col0 ++ "~p" ++ Col1 ++ "~p< >" ++ St0 ++ "~.3fs" ++ St1 ++ "" ++ St0 ++ "~.3fs" ++ St1 ++ "" ++ St0 ++ "died" ++ St1 ++ "" ++ to_string(Comment0) ++ "
\n\n\n"), + io:put_chars(Fd, "\n\n"), + case get(test_server_html_footer) of + undefined -> + io:put_chars(Fd, "\n\n"); + Footer -> + io:put_chars(Fd, Footer) + end, file:position(Fd, Pos); {error, epipe} -> %% The file is not seekable. We cannot erase what @@ -4393,6 +4458,28 @@ output_to_fd(Fd, Msg, _Sender) -> _ -> io:put_chars(Fd, "\n") 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,
" - "or cross cover analysis is not completed.\n" - "\n", []), + ["No cross cover modules exist for this application,", + xhtml("
","
"), + "or cross cover analysis is not completed.\n" + "\n"], []), file:close(CrossCoverLog). write_cover_result_table(CoverLog,Coverage) -> -- cgit v1.2.3