File 7051-otp_SUITE-Update-tests-for-non-recommended-functions.patch of Package erlang

From c089382b5bb889371a9452f8b4f7314711e371b9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org>
Date: Fri, 17 Feb 2023 06:28:16 +0100
Subject: [PATCH] otp_SUITE: Update tests for non-recommended functions

* There are no longer any calls to the `size/1` function in any OTP
application. `size/1` is not formally deprecated, but its use is not
recommended, and we should not use it in OTP code. From now on, use of
`size/1` in any OTP application will cause the
`otp_SUITE:call_to_size_1/1` test to fail.

* The only uses of the deprecated `now/0` function is from the `et`
application. From now on, `otp_SUITE:call_to_now_0/1` will forbid
calls to `now/0` from any other application than `et`.
---
 erts/test/otp_SUITE.erl | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl
index 7552dc80b3..1eccb59875 100644
--- a/erts/test/otp_SUITE.erl
+++ b/erts/test/otp_SUITE.erl
@@ -218,17 +218,13 @@ call_to_deprecated(Config) when is_list(Config) ->
     {comment,integer_to_list(length(DeprecatedCalls))++" calls to deprecated functions"}.
 
 call_to_size_1(Config) when is_list(Config) ->
-    %% Applications that do not call erlang:size/1:
-    Apps = [asn1,compiler,debugger,kernel,observer,parsetools,
-            runtime_tools,stdlib,tools],
+    %% Forbid the use of erlang:size/1 in all applications.
+    Apps = all_applications(Config),
     not_recommended_calls(Config, Apps, {erlang,size,1}).
 
 call_to_now_0(Config) when is_list(Config) ->
-    %% Applications that do not call erlang:now/0:
-    Apps = [asn1,common_test,compiler,debugger,dialyzer,
-            kernel,mnesia,observer,parsetools,reltool,
-            runtime_tools,sasl,stdlib,syntax_tools,
-            tools],
+    %% Forbid the use of erlang:now/0 in all applications except et.
+    Apps = all_applications(Config) -- [et],
     not_recommended_calls(Config, Apps, {erlang,now,0}).
 
 not_recommended_calls(Config, Apps0, MFA) ->
@@ -281,9 +277,14 @@ not_recommended_calls(Config, Apps0, MFA) ->
                     {comment, Mess}
             end;
         _ ->
-            ct:fail({length(CallsToMFA),calls_to_size_1})
+            ct:fail({length(CallsToMFA),calls_to,MFA})
     end.
 
+all_applications(Config) ->
+    Server = proplists:get_value(xref_server, Config),
+    {ok,AllApplications} = xref:q(Server, "A"),
+    AllApplications.
+
 is_present_application(Name, Server) ->
     Q = io_lib:format("~w : App", [Name]),
     case xref:q(Server, lists:flatten(Q)) of
-- 
2.35.3

openSUSE Build Service is sponsored by