LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File 0538-common_test-Adjust-some-calls-to-io-format.patch of Package erlang (Project home:Ledest:erlang:20)

From 8b21b2ef5c46f6a831beb9ee4445582c4558e8ba Mon Sep 17 00:00:00 2001
From: Hans Bolinder <hasse@erlang.org>
Date: Wed, 29 Aug 2018 15:45:33 +0200
Subject: [PATCH 1/4] common_test: Adjust some calls to io:format()

---
 lib/common_test/src/ct_framework.erl         | 32 ++++++++++-----------
 lib/common_test/src/ct_logs.erl              | 10 +++----
 lib/common_test/src/ct_master.erl            |  4 +--
 lib/common_test/src/ct_repeat.erl            |  2 +-
 lib/common_test/src/cth_log_redirect.erl     | 24 ++++++++--------
 lib/common_test/src/cth_surefire.erl         |  2 +-
 lib/common_test/src/test_server_ctrl.erl     | 42 +++++++++++++++-------------
 lib/common_test/test_server/ts_benchmark.erl |  2 +-
 8 files changed, 60 insertions(+), 58 deletions(-)

diff --git a/lib/common_test/src/ct_framework.erl b/lib/common_test/src/ct_framework.erl
index 7e98e6395f..506147474f 100644
--- a/lib/common_test/src/ct_framework.erl
+++ b/lib/common_test/src/ct_framework.erl
@@ -314,8 +314,8 @@ add_defaults(Mod,Func, GroupPath) ->
 	    ErrStr = io_lib:format("~n*** ERROR *** "
 				   "~w:suite/0 failed: ~tp~n",
 				   [Suite,Reason]),
-	    io:format(ErrStr, []),
-	    io:format(?def_gl, ErrStr, []),
+	    io:format("~ts", [ErrStr]),
+	    io:format(?def_gl, "~ts", [ErrStr]),
 	    {suite0_failed,{exited,Reason}};
 	SuiteInfo when is_list(SuiteInfo) ->
 	    case lists:all(fun(E) when is_tuple(E) -> true;
@@ -337,16 +337,16 @@ add_defaults(Mod,Func, GroupPath) ->
 					   "Invalid return value from "
 					   "~w:suite/0: ~tp~n",
 					   [Suite,SuiteInfo]),
-		    io:format(ErrStr, []),
-		    io:format(?def_gl, ErrStr, []),
+		    io:format("~ts", [ErrStr]),
+		    io:format(?def_gl, "~ts", [ErrStr]),
 		    {suite0_failed,bad_return_value}
 	    end;
 	SuiteInfo ->
 	    ErrStr = io_lib:format("~n*** ERROR *** "
 				   "Invalid return value from "
 				   "~w:suite/0: ~tp~n", [Suite,SuiteInfo]),
-	    io:format(ErrStr, []),
-	    io:format(?def_gl, ErrStr, []),
+	    io:format("~ts", [ErrStr]),
+	    io:format(?def_gl, "~ts", [ErrStr]),
 	    {suite0_failed,bad_return_value}
     end.
 
@@ -373,8 +373,8 @@ add_defaults1(Mod,Func, GroupPath, SuiteInfo) ->
 				      "Invalid return value from "
 				      "~w:group(~tw): ~tp~n",
 				      [Mod,GrName,BadGr0Val]),
-	    io:format(Gr0ErrStr, []),
-	    io:format(?def_gl, Gr0ErrStr, []),
+	    io:format("~ts", [Gr0ErrStr]),
+	    io:format(?def_gl, "~ts", [Gr0ErrStr]),
 	    {group0_failed,bad_return_value};
 	_ ->
 	    Args = if Func == init_per_group ; Func == end_per_group ->
@@ -395,8 +395,8 @@ add_defaults1(Mod,Func, GroupPath, SuiteInfo) ->
 					      "Invalid return value from "
 					      "~w:~tw/0: ~tp~n",
 					      [Mod,Func,BadTC0Val]),
-		    io:format(TC0ErrStr, []),
-		    io:format(?def_gl, TC0ErrStr, []),
+		    io:format("~ts", [TC0ErrStr]),
+		    io:format(?def_gl, "~ts", [TC0ErrStr]),
 		    {testcase0_failed,bad_return_value};
 		_ ->
 		    %% let test case info (also for all config funcs) override
@@ -972,11 +972,10 @@ error_notification(Mod,Func,_Args,{Error,Loc}) ->
     end,
 
     PrintError = fun(ErrorFormat, ErrorArgs) ->
-		       Div = "~n- - - - - - - - - - - - - - - - - - - "
-			     "- - - - - - - - - - - - - - - - - - - - -~n",
+                      Div = "\n- - - - - - - - - - - - - - - - - - - "
+                            "- - - - - - - - - - - - - - - - - - - - -\n",
 		       ErrorStr2 = io_lib:format(ErrorFormat, ErrorArgs),
-		       io:format(?def_gl, lists:concat([Div,ErrorStr2,Div,"~n"]),
-				 []),
+                      io:format(?def_gl, "~ts~n", [lists:concat([Div,ErrorStr2,Div])]),
 		       Link =
 			   "\n\n<a href=\"#end\">"
 			   "Full error description and stacktrace"
@@ -985,7 +984,8 @@ error_notification(Mod,Func,_Args,{Error,Loc}) ->
 		       ct_logs:tc_log(ct_error_notify,
 				      ?MAX_IMPORTANCE,
 				      "CT Error Notification",
-				      ErrorHtml2++Link, [], [])
+                                      "~ts", [ErrorHtml2++Link],
+                                      [])
 	       end,
     case Loc of
 	[{?MODULE,error_in_suite}] ->
@@ -1181,7 +1181,7 @@ get_all(Mod, ConfTests) ->
 		    ErrStr = io_lib:format("~n*** ERROR *** "
 					   "~w:all/0 failed: ~tp~n",
 					   [Mod,ExitReason]),
-		    io:format(?def_gl, ErrStr, []),
+		    io:format(?def_gl, "~ts", [ErrStr]),
 		    %% save the error info so it doesn't get printed twice
 		    ct_util:set_testdata_async({{error_in_suite,Mod},
 						ExitReason});
diff --git a/lib/common_test/src/ct_logs.erl b/lib/common_test/src/ct_logs.erl
index 07a1693d5d..814b80b8bd 100644
--- a/lib/common_test/src/ct_logs.erl
+++ b/lib/common_test/src/ct_logs.erl
@@ -542,7 +542,7 @@ tc_print(Category,Importance,Format,Args,Opts) ->
                     undefined -> atom_to_list(Category);
                     Hd        -> Hd
                 end,
-            Str = lists:concat([get_header(Heading),Format,"\n\n"]),
+            Str = lists:flatten([get_header(Heading),Format,"\n\n"]),
             try
                 io:format(?def_gl, Str, Args)
             catch
@@ -935,7 +935,7 @@ create_io_fun(FromPid, CtLogFd, EscChars) ->
 		    {_HdOrFt,S,A} -> {false,S,A};
 		    {S,A}         -> {true,S,A}
 		end,
-	    try io_lib:format(Str, Args) of
+	    try io_lib:format(lists:flatten(Str), Args) of
 		IoStr when Escapable, EscChars, IoList == [] ->
 		    escape_chars(IoStr);
 		IoStr when Escapable, EscChars ->
@@ -1138,10 +1138,10 @@ set_evmgr_gl(GL) ->
 
 open_ctlog(MiscIoName) ->
     {ok,Fd} = file:open(?ct_log_name,[write,{encoding,utf8}]),
-    io:format(Fd, header("Common Test Framework Log", {[],[1,2],[]}), []),
+    io:format(Fd, "~ts", [header("Common Test Framework Log", {[],[1,2],[]})]),
     case file:consult(ct_run:variables_file_name("../")) of
 	{ok,Vars} ->
-	    io:format(Fd, config_table(Vars), []);
+	    io:format(Fd, "~ts", [config_table(Vars)]);
 	{error,Reason} ->
 	    {ok,Cwd} = file:get_cwd(),
 	    Dir = filename:dirname(Cwd),
@@ -1213,7 +1213,7 @@ print_style_error(Fd, IoFormat, StyleSheet, Reason) ->
 
 close_ctlog(Fd) ->
     io:format(Fd, "\n</pre>\n", []),
-    io:format(Fd, [xhtml("<br><br>\n", "<br /><br />\n") | footer()], []),
+    io:format(Fd, "~ts", [[xhtml("<br><br>\n", "<br /><br />\n") | footer()]]),
     ok = file:close(Fd).
 
 %%%-----------------------------------------------------------------
diff --git a/lib/common_test/src/ct_master.erl b/lib/common_test/src/ct_master.erl
index fd33ee2280..9fc169789c 100644
--- a/lib/common_test/src/ct_master.erl
+++ b/lib/common_test/src/ct_master.erl
@@ -350,7 +350,7 @@ master_loop(#state{node_ctrl_pids=[],
 			  io_lib:format("~-40.40.*ts~tp\n",
 					[$_,atom_to_list(Node),Result])
 		  end,lists:reverse(Finished)),
-    log(all,"TEST RESULTS",Str,[]),
+    log(all,"TEST RESULTS","~ts", [Str]),
     log(all,"Info","Updating log files",[]),
     refresh_logs(LogDirs,[]),
     
@@ -574,7 +574,7 @@ refresh_logs([],Refreshed) ->
 			  io_lib:format("Refreshing logs in ~tp... ~tp",
 					[D,Result])
 		  end,Refreshed),
-    log(all,"Info",Str,[]).
+    log(all,"Info","~ts", [Str]).
 
 %%%-----------------------------------------------------------------
 %%% NODE CONTROLLER, runs and controls tests on a test node.
diff --git a/lib/common_test/src/ct_repeat.erl b/lib/common_test/src/ct_repeat.erl
index 8b1c7d47bb..b97c6e59e7 100644
--- a/lib/common_test/src/ct_repeat.erl
+++ b/lib/common_test/src/ct_repeat.erl
@@ -278,7 +278,7 @@ log_loop_info(Args) ->
 		    ForceStop ->
 			io_lib:format("force_stop is set to: ~w",[ForceStop])
 		end,			
-	    ct_logs:log("Test loop info",LogStr1++LogStr2++LogStr3++LogStr4,[])
+	    ct_logs:log("Test loop info","~ts", [LogStr1++LogStr2++LogStr3++LogStr4])
     end.
 
 ts(Secs) ->
diff --git a/lib/common_test/src/cth_surefire.erl b/lib/common_test/src/cth_surefire.erl
index b0742717ae..c9b4cb10c6 100644
--- a/lib/common_test/src/cth_surefire.erl
+++ b/lib/common_test/src/cth_surefire.erl
@@ -235,7 +235,7 @@ close_suite(#state{ test_cases = TCs, url_base = UrlBase } = State) ->
 terminate(State = #state{ test_cases = [] }) ->
     {ok,D} = file:open(State#state.filepath,[write,{encoding,utf8}]),
     io:format(D, "<?xml version=\"1.0\" encoding= \"UTF-8\" ?>", []),
-    io:format(D, to_xml(State), []),
+    io:format(D, "~ts", [to_xml(State)]),
     catch file:sync(D),
     catch file:close(D);
 terminate(State) ->
diff --git a/lib/common_test/src/test_server_ctrl.erl b/lib/common_test/src/test_server_ctrl.erl
index 34f2feb33c..1518c6e8d6 100644
--- a/lib/common_test/src/test_server_ctrl.erl
+++ b/lib/common_test/src/test_server_ctrl.erl
@@ -1558,7 +1558,7 @@ do_test_cases(TopCases, SkipCases,
 			 Html1}
 		end,
 
-	    print(html, Header),
+	    print(html, "~ts", [Header]),
 
 	    print(html, xhtml("<p>", "<h4>")),
 	    print_timestamp(html, "Test started at "),
@@ -1605,10 +1605,10 @@ do_test_cases(TopCases, SkipCases,
 		  [?suitelog_name,CoverLog,?unexpected_io_log]),
 	    print(html,
 		  "<p>~ts</p>\n" ++
-		  xhtml(["<table bgcolor=\"white\" border=\"3\" cellpadding=\"5\">\n",
-			 "<thead>\n"],
-			["<table id=\"",?sortable_table_name,"\">\n",
-			 "<thead>\n"]) ++
+		  xhtml("<table bgcolor=\"white\" border=\"3\" cellpadding=\"5\">\n" ++
+			 "<thead>\n",
+			"<table id=\"" ++ ?sortable_table_name ++ "\">\n" ++
+			 "<thead>\n") ++
 		      "<tr><th>Num</th><th>Module</th><th>Group</th>" ++
 		      "<th>Case</th><th>Log</th><th>Time</th><th>Result</th>" ++
 		      "<th>Comment</th></tr>\n</thead>\n<tbody>\n",
@@ -3306,7 +3306,8 @@ skip_case1(Type, CaseNum, Mod, Func, Comment, Mode) ->
        true ->
 	    print(2,"*** Skipping test case #~w ~tw ***", [CaseNum,{Mod,Func}])
     end,
-    TR = xhtml("<tr valign=\"top\">", ["<tr class=\"",odd_or_even(),"\">"]),	       
+    TR = xhtml("<tr valign=\"top\">",
+               "<tr class=\"" ++ odd_or_even() ++ "\">"),
     GroupName =	case get_name(Mode) of
 		    undefined -> "";
 		    Name      -> cast_to_list(Name)
@@ -3796,8 +3797,8 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
     end,
 
     print(minor,
-	  escape_chars(io_lib:format("Config value:\n\n    ~tp\n", [Args2Print])),
-	  []),
+          "~ts",
+	  [escape_chars(io_lib:format("Config value:\n\n    ~tp\n", [Args2Print]))]),
     print(minor, "Current directory is ~tp\n", [Cwd]),
 
     GrNameStr =	case GrName of
@@ -3806,7 +3807,7 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
 		end,
     print(major, "=started       ~s", [lists:flatten(timestamp_get(""))]),
     {{Col0,Col1},Style} = get_font_style((RunInit==run_init), Mode),
-    TR = xhtml("<tr valign=\"top\">", ["<tr class=\"",odd_or_even(),"\">"]),
+    TR = xhtml("<tr valign=\"top\">", "<tr class=\"" ++ odd_or_even() ++ "\">"),
     EncMinorBase = uri_encode(MinorBase),
     print(html,	TR ++ "<td>" ++ Col0 ++ "~ts" ++ Col1 ++ "</td>"
 	  "<td>" ++ Col0 ++ "~w" ++ Col1 ++ "</td>"
@@ -3831,7 +3832,7 @@ run_test_case1(Ref, Num, Mod, Func, Args, RunInit,
     print(minor, "<a name=\"end\"></a>", [], internal_raw),
     print(minor, "\n", [], internal_raw),
     print_timestamp(minor, "Ended at "),
-    print(major, "=ended         ~s", [lists:flatten(timestamp_get(""))]),
+    print(major, "=ended         ~s", [timestamp_get("")]),
 
     do_unless_parallel(Main, fun() -> file:set_cwd(filename:dirname(TSDir)) end),
 
@@ -4075,9 +4076,9 @@ progress(failed, CaseNum, Mod, Func, GrName, Loc, {testcase_aborted,Reason}, _T,
     FormatLoc = test_server_sup:format_loc(Loc),
     print(minor, "=== Location: ~ts", [FormatLoc]),
     print(minor,
-	  escape_chars(io_lib:format("=== Reason: {testcase_aborted,~tp}",
-				     [Reason])),
-	  []),
+          "~ts",
+	  [escape_chars(io_lib:format("=== Reason: {testcase_aborted,~tp}",
+				     [Reason]))]),
     failed;
 
 progress(failed, CaseNum, Mod, Func, GrName, unknown, Reason, Time,
@@ -4115,8 +4116,8 @@ progress(failed, CaseNum, Mod, Func, GrName, unknown, Reason, Time,
     print(minor, "=== Location: ~w", [unknown]),
     {FStr,FormattedReason} = format_exception(Reason),
     print(minor,
-	  escape_chars(io_lib:format("=== Reason: " ++ FStr, [FormattedReason])),
-	  []),
+          "~ts",
+	  [escape_chars(io_lib:format("=== Reason: " ++ FStr, [FormattedReason]))]),
     failed;
 
 progress(failed, CaseNum, Mod, Func, GrName, Loc, Reason, Time,
@@ -4150,8 +4151,9 @@ progress(failed, CaseNum, Mod, Func, GrName, Loc, Reason, Time,
     FormatLoc = test_server_sup:format_loc(LocMin),
     print(minor, "=== Location: ~ts", [FormatLoc]),
     {FStr,FormattedReason} = format_exception(Reason),
-    print(minor, "=== Reason: " ++
-	      escape_chars(io_lib:format(FStr, [FormattedReason])), []),
+    print(minor, "~ts",
+          ["=== Reason: " ++
+           escape_chars(io_lib:format(FStr, [FormattedReason]))]),
     failed;
 
 progress(ok, _CaseNum, Mod, Func, GrName, _Loc, RetVal, Time,
@@ -4184,8 +4186,8 @@ progress(ok, _CaseNum, Mod, Func, GrName, _Loc, RetVal, Time,
 	  "~ts</tr>\n",
 	  [TimeStr,Comment]),
     print(minor,
-	  escape_chars(io_lib:format("=== Returned value: ~tp", [RetVal])),
-	  []),
+          "~ts",
+	  [escape_chars(io_lib:format("=== Returned value: ~tp", [RetVal]))]),
     ok.
 
 %%--------------------------------------------------------------------
@@ -4542,7 +4544,7 @@ timestamp_get(Leader) ->
 
 timestamp_get_internal(Leader, Format) ->
     {YY,MM,DD,H,M,S} = time_get(),
-    io_lib:format(Format, [Leader,YY,MM,DD,H,M,S]).
+    lists:flatten(io_lib:format(Format, [Leader,YY,MM,DD,H,M,S])).
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %% time_get() -> {YY,MM,DD,H,M,S}
diff --git a/lib/common_test/test_server/ts_benchmark.erl b/lib/common_test/test_server/ts_benchmark.erl
index e4e06b54c2..a9486262b3 100644
--- a/lib/common_test/test_server/ts_benchmark.erl
+++ b/lib/common_test/test_server/ts_benchmark.erl
@@ -45,7 +45,7 @@ run(Specs, Opts, Vars) ->
      || Spec <- Specs],
     file:delete(filename:join(Cwd,"latest_benchmark")),
     {ok,D} = file:open(filename:join(Cwd,"latest_benchmark"),[write]),
-    io:format(D,BDir,[]),
+    io:format(D,"~ts", [BDir]),
     file:close(D).
     
 
-- 
2.16.4