⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cover_web.erl

📁 OTP是开放电信平台的简称
💻 ERL
📖 第 1 页 / 共 3 页
字号:
                ++ Content ++"</TABLE>".format_cover_call({error,_},_)->    ["<TR><TD>\n",     "<BR><BR><BR><BR>\n",     "<FONT SIZE=5>The selected module is not Cover Compiled</FONT>\n",     "<BR>\n",     "</TD></TR>\n"];format_cover_call({ok,{Mod,Calls}},mod)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=5><B>Module calls</B></TD></TR>\n",      "<TR><TD COLSPAN=4><I>Module</I></TD>",     "<TD ALIGN=\"right\"><I>Number of calls</I></TD></TR>\n",     "<TR><TD COLSPAN=4>" ++ atom_to_list(Mod) ++"</TD>"     "<TD ALIGN=\"right\">" ++ integer_to_list(Calls)++"</TD></TR>\n"];format_cover_call({ok,Calls},func)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=5><B>Function calls</B></TD></TR>\n",     "<TR><TD><I>Module</I></TD><TD><I>Function</I></TD>",     "<TD COLSPAN=2 ALIGN=\"right\"><I>Arity</I></TD>",     "<TD ALIGN=\"right\"><I>Number of calls </I></TD></TR>\n",     lists:append(       lists:map(	 fun({{Mod,Func,Arity},Nr_of_calls})->		 ["<TR><TD WIDTH=\"20%\">"++ atom_to_list(Mod)++"</TD>\n",		  "<TD WIDTH=\"20%\" >" ++ atom_to_list(Func) ++" </TD>\n",		  "<TD COLSPAN=2 WIDTH=\"40%\" ALIGN=\"right\">",		  integer_to_list(Arity), 		  "</TD>\n",		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Nr_of_calls), 		  "</TD></TR>\n"]	 end,	 Calls))];format_cover_call({ok,Calls},clause)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=5><B>Clause calls</B></TD></TR>\n",     "<TR><TD><I>Module</I></TD><TD><I>Function</I></TD>",     "<TD ALIGN=\"right\"><I>Arity</I></TD>",     "<TD ALIGN=\"right\"><I>Ordinal</I></TD>",     "<TD ALIGN=\"right\"><I>Number of calls</I></TD></TR>\n",     lists:append(       lists:map(	 fun({{Mod,Func,Arity,Ord},Nr_of_calls})->		 ["<TR><TD WIDTH=\"20%\" >", atom_to_list(Mod), "</TD>\n",  		  "<TD WIDTH=\"20%\" >", atom_to_list(Func), "</TD>\n",		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Arity),		  "</TD>\n",		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Ord),		  "</TD>\n",		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Nr_of_calls),		  "</TD></TR>\n"]	 end,	 Calls))].error_body()->    ["<TABLE WIDTH=\"100%\" BORDER=1>\n",     "<TR ALIGN=\"center\">\n",     "<TD>\n",     "<BR><BR><BR><BR><BR><BR>\n",     "<FONT SIZE=5>The selected module is not Cover Compiled</FONT>\n",     "<BR>\n",     "</TD>\n",     "</TR>\n",     "</TABLE>\n"].%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                     %% The functions that builds the body of the page that shows coverage  %% 		                                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%coverage_result(Input)->    Mod = list_to_atom(get_input_data(Input, "module")),    case cover:analyse(Mod,coverage) of	{error,_}->	    error_body();	{ok,_} ->	    coverage_result2(Mod,Input)    end.coverage_result2(Mod,Input)->    Result = 	case get_input_data(Input,"what") of	    "mod" ->		coverage_result(mod,Mod);	    "func" ->		coverage_result(func,Mod);	    "clause" ->		coverage_result(clause,Mod);	    _->		coverage_result(all,Mod)	end,    result_choice("coverage",Mod) ++ Result.coverage_result(Mode,Module)->    Content = 	case Mode of	    mod->		format_cover_coverage(cover:analyse(Module,coverage,module),				      mod);	    func->		format_cover_coverage(cover:analyse(Module,coverage,function),				      func);	    clause->		format_cover_coverage(cover:analyse(Module,coverage,clause),				      clause);	    _->		format_cover_coverage(cover:analyse(Module,coverage,module),				      mod) ++		   format_cover_coverage(cover:analyse(Module,coverage,function),					 func)++		   format_cover_coverage(cover:analyse(Module,coverage,clause),					 clause)	      end,    getModDate(Module,date())++"<BR>"++    "<TABLE WIDTH=\"100%\" BORDER=1>"                ++ Content ++"</TABLE>".getModDate(Module,{Year,Mon,Day})->    "<TABLE>      <TR>        <TD>Module:</TD>         <TD>" ++ atom_to_list(Module) ++ "</TD>       </TR>     <TR>        <TD>Date:</TD>         <TD>" ++ integer_to_list(Day) ++ "/" ++                  integer_to_list(Mon) ++"&nbsp;-&nbsp;"++                  integer_to_list(Year)  ++        "</TD>      </TR>   </TABLE>".format_cover_coverage({error,_},_)->     "<TR><TD>      <BR><BR><BR><BR>      <FONT SIZE=5>The selected module is not Cover Compiled</FONT>      <BR>        </TD></TR>";format_cover_coverage({ok,{Mod,{Cov,Not_cov}}},mod)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=6><B>Module coverage</B></TD></TR>\n",     "<TR><TD COLSPAN=4><I>Module</I></TD>\n",     "<TD ALIGN=\"right\"><I>Covered</I></TD>\n"     "<TD ALIGN=\"RIGHT\" NOWRAP=\"true\"><I>Not Covered</I></TD>\n",     "</TR>\n",     "<TR><TD COLSPAN=4>", atom_to_list(Mod), "</TD>\n"     "<TD ALIGN=\"right\">", integer_to_list(Cov), "</TD>\n"     "<TD ALIGN=\"right\" >", integer_to_list(Not_cov), "</TD></TR>\n"];format_cover_coverage({ok,Cov_res},func)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=6><B>Function coverage</B></TD>\n",     "</TR>\n",     "<TR><TD><I>Module</I></TD><TD><I>Function</I></TD>",     "<TD ALIGN=\"right\"><I>Arity</I></TD>",     "<TD COLSPAN=2 ALIGN=\"right\"><I>Covered</I></TD>",     "<TD ALIGN=\"right\" STYLE=\"white-space:nowrap\"><I>Not Covered</I></TD>",     "</TR>\n",     lists:append(       lists:map(	 fun({{Mod,Func,Arity},{Cov,Not_cov}})->		 ["<TR><TD WIDTH=\"20%\" >"++ atom_to_list(Mod) ++" </TD>\n",		  "<TD WIDTH=\"20%\" >" ++ atom_to_list(Func) ++"</TD>\n",		  "<TD WIDTH=\"40%\" ALIGN=\"right\">",		  integer_to_list(Arity),		  "</TD>\n",  		  "<TD WIDTH=\"40%\" ALIGN=\"right\" COLSPAN=2>",		  integer_to_list(Cov),		  "</TD>\n"		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Not_cov),		  "</TD></TR>\n"]	 end,	 Cov_res))];format_cover_coverage({ok,Cov_res},clause)->    ["<TR BGCOLOR=\"#8899AA\"><TD COLSPAN=6><B>Clause coverage</B></TD></TR>\n",     "<TR><TD><I>Module</I></TD><TD><I>Function</I></TD>\n",     "<TD ALIGN=\"right\"><I>Arity</I></TD>\n",     "<TD ALIGN=\"right\"><I>Ordinal<I></TD>\n",     "<TD ALIGN=\"right\">Covered</TD>\n",     "<TD ALIGN=\"right\" STYLE=\"white-space:nowrap\">Not Covered</TD></TR>\n",     lists:append(       lists:map(	 fun({{Mod,Func,Arity,Ord},{Cov,Not_cov}})->		 ["<TR><TD WIDTH=\"20%\" >"++ atom_to_list(Mod) ++"</TD>\n",  		  "<TD WIDTH=\"20%\" >" ++ atom_to_list(Func) ++" </TD>\n",		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Arity),		  "</TD>\n"		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Ord),		  "</TD>\n"		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Cov),		  "</TD>\n"		  "<TD WIDTH=\"20%\" ALIGN=\"right\">",		  integer_to_list(Not_cov),		  "</TD></TR>\n"]	 end,	 Cov_res))].%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                     %% The functions that builds the body of the import page               %% 		                                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%import_body(Dir,Err) ->    [reload_menu_script(Err),     "<H1 ALIGN=center>Import</H1>\n",     "<TABLE BORDER=0 WIDTH=600 ALIGN=center>\n",          "<TR><TD BGCOLOR=",?INFO_BG_COLOR,">\n",     "<P>You can import coverage data from a previous analysis. If you do so\n",     "the imported data will be merged with the current coverage data.\n",     "<P>You can export data from the current analysis from the \"Result\"\n",     "page.\n",     "<P>Select the file to import here.\n",     "</TD></TR>\n",     "<TR><TD ALIGN=center><BR><BR>\n",     "<FORM NAME=change_import_dir METHOD=post ACTION=\"./import\">\n",     "<B>Change directory:</B><BR>\n",     "<INPUT TYPE=text NAME=\"file\" SIZE=30 VALUE=",Dir,">",     "<INPUT TYPE=hidden NAME=dir VALUE=",Dir,">\n",     "<INPUT TYPE=submit VALUE=Ok><BR>\n",     "</FORM>\n",     browse_import(Dir),     "</TABLE>"].browse_import(Dir) ->    {ok,List} = file:list_dir(Dir),    Sorted = lists:reverse(lists:sort(List)),    {Dirs,Files} = filter_files(Dir,Sorted,[],[]),    ["<FORM NAME=browse_import METHOD=post ACTION=\"./import\">\n"     "<SELECT NAME=file TITLE=\"Select import file\" SIZE=10>\n",     "<OPTION VALUE=\"..\" onDblClick=submit()>../</OPTION>\n",     Dirs,     Files,     "</SELECT>\n",     "<INPUT TYPE=hidden NAME=dir VALUE=",Dir,">\n",     "<BR><INPUT TYPE=submit VALUE=Ok>\n"     "</FORM>\n"].filter_files(Dir,[File|Files],Ds,Fs) ->    case filename:extension(File) of	".coverdata" ->	    Fs1 = ["<OPTION VALUE=",File," onDblClick=submit()>",		   File,"</OPTION>\n" | Fs],	    filter_files(Dir,Files,Ds,Fs1);	_ ->	    FullName = filename:join(Dir,File),	    case filelib:is_dir(FullName) of		true ->		    Ds1 = ["<OPTION VALUE=",File," onDblClick=submit()>",			   File,"/</OPTION>\n" | Ds],		    filter_files(Dir,Files,Ds1,Fs);		false ->		    filter_files(Dir,Files,Ds,Fs)	    end    end;filter_files(_Dir,[],Ds,Fs) ->    {Ds,Fs}.do_import(Input) ->    case parse(Input) of	[{"file",File0},{"dir",Dir}] ->	    File = filename:join(Dir,File0),	    case filelib:is_dir(File) of		true ->		    import_frame1(File);		false ->		    case filelib:is_file(File) of			true ->			    case cover:import(File) of				ok ->				    import_frame1(Dir);				{error,{cant_open_file,ExportFile,_Reason}} ->				    import_frame1(Dir,						  "Error importing file\\n\\\"" 						  ++ ExportFile ++ "\\\"")			    end;			false ->			    import_frame1(Dir,					  "Error importing file\\n\\\"" ++ 					  File ++ "\\\"")		    end	    end;	[{"dir",Dir}] ->	    import_frame1(Dir,"No file is selected")    end.	        %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%                                                                     %% Different private helper functions                                   %% 		                                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%Create the Header for the page If we now the mimetype use that type %%%%otherwise use text                                                  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  header() ->    header("text/html").header(MimeType) ->    "Pragma:no-cache\r\n" ++    "Content-type: " ++ MimeType ++ "\r\n\r\n".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%    %%Create the Htmlheader set the title of the page                     %%       %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%html_header(Title) ->        "<HTML>\n" ++	"<HEAD>\n" ++	"<TITLE>" ++ Title ++  "</TITLE>\n" ++	"</HEAD>\n"	"<BODY BGCOLOR=\"#FFFFFF\">\n".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Close the body- and Html tags                                      %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%html_end()->    "</BODY></HTML>".%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% A script which reloads the menu frame and possibly pops up an alert%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%reload_menu_script(Err) ->    ["<SCRIPT>\n",     "function reloadMenu()\n",     "  {\n",     "    parent.menu.document.location.href=\"./menu_frame\";\n",     case Err of	 "" -> "";	 _ -> "    alert(\""++Err++"\");\n"     end,     case get_warnings() of	 [] -> 	     "";	 Warnings -> 	     "    alert(\""++fix_newline(lists:flatten(Warnings))++"\");\n"     end,     "  }\n",     "</SCRIPT>\n",     "<BODY onLoad=reloadMenu() BGCOLOR=\"#FFFFFF\">"].fix_newline([$\n|Rest]) ->    [$\\,$n|fix_newline(Rest)];fix_newline([$"|Rest]) ->    [$\\,$"|fix_newline(Rest)];fix_newline([Char|Rest]) ->    [Char|fix_newline(Rest)];fix_newline([]) ->    [].%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Control the input data and return the intresting values or error   %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%get_input_data(Input,Key)->    case lists:keysearch(Key,1,parse(Input)) of	{value,{Key,Value}} ->	    Value;	false ->	    undefined    end.parse(Input) ->    httpd:parse_query(Input).get_warnings() ->    cover_group_leader_proc ! {self(), get_warnings},    receive {warnings,Warnings} ->	    Warnings    end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -