Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:Ledest:erlang:25
erlang
3581-Check-for-non-recommended-functions-only-i...
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 3581-Check-for-non-recommended-functions-only-in-OTP-code.patch of Package erlang
From 6dbbc8a8cf05a03e47bbfad234717ef494397caa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Gustavsson?= <bjorn@erlang.org> Date: Thu, 30 Mar 2023 10:51:52 +0200 Subject: [PATCH] Check for non-recommended functions only in OTP code --- erts/test/otp_SUITE.erl | 60 ++++++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 24 deletions(-) diff --git a/erts/test/otp_SUITE.erl b/erts/test/otp_SUITE.erl index 54b60c74ad..40e2be0a85 100644 --- a/erts/test/otp_SUITE.erl +++ b/erts/test/otp_SUITE.erl @@ -219,12 +219,12 @@ call_to_deprecated(Config) when is_list(Config) -> call_to_size_1(Config) when is_list(Config) -> %% Forbid the use of erlang:size/1 in all applications. - Apps = all_applications(Config), + Apps = all_otp_applications(Config), not_recommended_calls(Config, Apps, {erlang,size,1}). call_to_now_0(Config) when is_list(Config) -> %% Forbid the use of erlang:now/1 in all applications except et. - Apps = all_applications(Config) -- [et], + Apps = all_otp_applications(Config) -- [et], not_recommended_calls(Config, Apps, {erlang,now,0}). not_recommended_calls(Config, Apps0, MFA) -> @@ -280,10 +280,16 @@ not_recommended_calls(Config, Apps0, MFA) -> ct:fail({length(CallsToMFA),calls_to,MFA}) end. -all_applications(Config) -> +all_otp_applications(Config) -> Server = proplists:get_value(xref_server, Config), {ok,AllApplications} = xref:q(Server, "A"), - AllApplications. + OtpAppsMap = get_otp_applications(Config), + [App || App <- AllApplications, is_map_key(App, OtpAppsMap)]. + +get_otp_applications(Config) -> + DataDir = proplists:get_value(data_dir, Config), + [Current|_] = read_otp_version_table(DataDir), + read_version_lines([Current]). is_present_application(Name, Server) -> Q = io_lib:format("~w : App", [Name]), @@ -495,7 +501,7 @@ test_runtime_dependencies_versions(Config) -> IgnoreApps = [], IgnoreUndefs = ignore_undefs(), - FirstVersionForApp = read_otp_version_table(DataDir), + FirstVersionForApp = get_first_app_versions(DataDir), case {element(1, os:type()) =:= unix, not is_development_build(DataDir), @@ -549,25 +555,9 @@ ignore_undefs() -> %% Read the otp_versions.table file and create a mapping from application name %% the first version for each application. -read_otp_version_table(DataDir) -> - VersionTableFile = filename:join(DataDir, "otp_versions.table"), - {ok, Contents} = file:read_file(VersionTableFile), - Lines = binary:split(Contents, <<"\n">>, [global,trim]), - read_version_lines(Lines, #{}). - -read_version_lines([Line|Lines], Map0) -> - [<<"OTP-",_/binary>>, <<":">> | Apps] = binary:split(Line, <<" ">>, [global,trim]), - Map = lists:foldl(fun(App, Acc) -> - case binary:split(App, <<"-">>) of - [Name, _Version] -> - Acc#{binary_to_atom(Name) => binary_to_list(App)}; - [_] -> - Acc - end - end, Map0, Apps), - read_version_lines(Lines, Map); -read_version_lines([], Map) -> - Map. +get_first_app_versions(DataDir) -> + Lines = read_otp_version_table(DataDir), + read_version_lines(Lines). test_runtime_dependencies_versions_rels(IgnoreApps, IgnoreUndefs, FirstVersionForApp, OtpReleasesWc) -> @@ -744,3 +734,25 @@ start_xref_server(Server, Mode) -> end, Server. + +read_otp_version_table(DataDir) -> + VersionTableFile = filename:join(DataDir, "otp_versions.table"), + {ok, Contents} = file:read_file(VersionTableFile), + binary:split(Contents, <<"\n">>, [global,trim]). + +read_version_lines(Lines) -> + read_version_lines(Lines, #{}). + +read_version_lines([Line|Lines], Map0) -> + [<<"OTP-",_/binary>>, <<":">> | Apps] = binary:split(Line, <<" ">>, [global,trim]), + Map = lists:foldl(fun(App, Acc) -> + case binary:split(App, <<"-">>) of + [Name, _Version] -> + Acc#{binary_to_atom(Name) => binary_to_list(App)}; + [_] -> + Acc + end + end, Map0, Apps), + read_version_lines(Lines, Map); +read_version_lines([], Map) -> + Map. -- 2.35.3
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor