File 1062-bif_SUITE-Skip-dialyzer-dependent-tests-when-dialyze.patch of Package erlang

From 1b7fb2af62ef0ffc7c044deacba9fdb00170a7a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Mon, 7 Dec 2020 14:50:42 +0100
Subject: [PATCH] bif_SUITE: Skip dialyzer-dependent tests when dialyzer isn't
 built

---
 erts/emulator/test/bif_SUITE.erl | 43 +++++++++++++++++++-------------
 1 file changed, 25 insertions(+), 18 deletions(-)

diff --git a/erts/emulator/test/bif_SUITE.erl b/erts/emulator/test/bif_SUITE.erl
index 91d21eeaa8..8eb2bb9719 100644
--- a/erts/emulator/test/bif_SUITE.erl
+++ b/erts/emulator/test/bif_SUITE.erl
@@ -23,8 +23,9 @@
 -include_lib("common_test/include/ct.hrl").
 -include_lib("kernel/include/file.hrl").
 
--export([all/0, suite/0,
-	 display/1, display_huge/0,
+-export([all/0, suite/0, init_per_testcase/2, end_per_testcase/2]).
+
+-export([display/1, display_huge/0,
 	 erl_bif_types/1,guard_bifs_in_erl_bif_types/1,
 	 shadow_comments/1,
 	 specs/1,improper_bif_stubs/1,auto_imports/1,
@@ -58,6 +59,28 @@ all() ->
      erl_crash_dump_bytes, min_max, erlang_halt, is_builtin,
      error_stacktrace, error_stacktrace_during_call_trace].
 
+init_per_testcase(guard_bifs_in_erl_bif_types, Config) when is_list(Config) ->
+    skip_missing_erl_bif_types(Config);
+init_per_testcase(erl_bif_types, Config) when is_list(Config) ->
+    skip_missing_erl_bif_types(Config);
+init_per_testcase(shadow_comments, Config) when is_list(Config) ->
+    skip_missing_erl_bif_types(Config);
+init_per_testcase(Func, Config) when is_atom(Func), is_list(Config) ->
+    Config.
+
+end_per_testcase(_Func, _Config) ->
+    ok.
+
+%% erl_bif_types comes from dialyzer which some test runs skip building, so
+%% we'll skip the tests that use it as the result shouldn't vary based on
+%% platform. The majority build it so we'll have plenty coverage either way.
+skip_missing_erl_bif_types(Config) ->
+    c:l(erl_bif_types),
+    case erlang:function_exported(erl_bif_types, module_info, 0) of
+        false -> {skip, "erl_bif_types not compiled"};
+        true -> Config
+    end.
+
 %% Uses erlang:display to test that erts_printf does not do deep recursion
 display(Config) when is_list(Config) ->
     Pa = filename:dirname(code:which(?MODULE)),
@@ -101,8 +124,6 @@ display_string(Config) when is_list(Config) ->
     deeep(N,[hello]).
 
 erl_bif_types(Config) when is_list(Config) ->
-    ensure_erl_bif_types_compiled(),
-
     List0 = erlang:system_info(snifs),
 
     %% Ignore missing type information for hipe BIFs.
@@ -153,8 +174,6 @@ erl_bif_types_3(List) ->
     end.
 
 guard_bifs_in_erl_bif_types(_Config) ->
-    ensure_erl_bif_types_compiled(),
-
     List0 = erlang:system_info(snifs),
     List = [{F,A} || {erlang,F,A} <- List0,
 		     erl_internal:guard_bif(F, A)],
@@ -174,8 +193,6 @@ guard_bifs_in_erl_bif_types(_Config) ->
     end.
 
 shadow_comments(_Config) ->
-    ensure_erl_bif_types_compiled(),
-
     ErlangList = [{erlang,F,A} || {F,A} <- erlang:module_info(exports),
 				  not is_operator(F,A)],
     List0 = erlang:system_info(snifs),
@@ -243,16 +260,6 @@ extract_comments(Mod, Path) ->
 	 {list_to_atom(M),list_to_atom(F),list_to_integer(A)}
      end || L <- Lines].
 
-ensure_erl_bif_types_compiled() ->
-    c:l(erl_bif_types),
-    case erlang:function_exported(erl_bif_types, module_info, 0) of
-	false ->
-	    %% Fail cleanly.
-	    ct:fail("erl_bif_types not compiled");
-	true ->
-	    ok
-    end.
-
 known_types({M,F,A}) ->
     erl_bif_types:is_known(M, F, A).
 
-- 
2.26.2

openSUSE Build Service is sponsored by