]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] gh-103053: Skip test_freeze_simple_script() on PGO build (#109591) (#109614)
authorVictor Stinner <vstinner@python.org>
Mon, 2 Oct 2023 15:04:19 +0000 (17:04 +0200)
committerGitHub <noreply@github.com>
Mon, 2 Oct 2023 15:04:19 +0000 (17:04 +0200)
gh-103053: Skip test_freeze_simple_script() on PGO build (#109591)

Skip test_freeze_simple_script() of test_tools.test_freeze if Python
is built with "./configure --enable-optimizations", which means with
Profile Guided Optimization (PGO): it just makes the test too slow.
The freeze tool is tested by many other CIs with other (faster)
compiler flags.

test.pythoninfo now gets also get_build_info() of
test.libregrtests.utils.

(cherry picked from commit 81cd1bd713624c3d26b647f3d28f2fd905887a0d)

Lib/test/libregrtest/utils.py
Lib/test/pythoninfo.py
Lib/test/support/__init__.py
Lib/test/test_tools/test_freeze.py
Misc/NEWS.d/next/Tests/2023-09-20-02-32-17.gh-issue-103053.AoUJuK.rst [new file with mode: 0644]

index 5e16b1ae054a269b55ed963b40e1facbd6e0d682..28acb531f4d93e8933af37124d1d7b1e121a5a2a 100644 (file)
@@ -259,16 +259,8 @@ def get_build_info():
     elif '-flto' in ldflags_nodist:
         optimizations.append('LTO')
 
-    # --enable-optimizations
-    pgo_options = (
-        # GCC
-        '-fprofile-use',
-        # clang: -fprofile-instr-use=code.profclangd
-        '-fprofile-instr-use',
-        # ICC
-        "-prof-use",
-    )
-    if any(option in cflags_nodist for option in pgo_options):
+    if support.check_cflags_pgo():
+        # PGO (--enable-optimizations)
         optimizations.append('PGO')
     if optimizations:
         build.append('+'.join(optimizations))
index 8d7fb9f4f2103b58a916ea318c26966458cf8528..860c4cc4e0a818771e40179b751589d51e153041 100644 (file)
@@ -867,6 +867,15 @@ def collect_fips(info_add):
         pass
 
 
+def collect_libregrtest_utils(info_add):
+    try:
+        from test.libregrtest import utils
+    except ImportError:
+        return
+
+    info_add('libregrtests.build_info', ' '.join(utils.get_build_info()))
+
+
 def collect_info(info):
     error = False
     info_add = info.add
@@ -904,6 +913,7 @@ def collect_info(info):
         collect_tkinter,
         collect_windows,
         collect_zlib,
+        collect_libregrtest_utils,
 
         # Collecting from tests should be last as they have side effects.
         collect_test_socket,
index b6350e4e5292fede9731261c19525a882d0061a8..389d39c83bc0064be95437cba730d5301e6eaf4f 100644 (file)
@@ -781,6 +781,21 @@ def python_is_optimized():
     return final_opt not in ('', '-O0', '-Og')
 
 
+def check_cflags_pgo():
+    # Check if Python was built with ./configure --enable-optimizations:
+    # with Profile Guided Optimization (PGO).
+    cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or ''
+    pgo_options = (
+        # GCC
+        '-fprofile-use',
+        # clang: -fprofile-instr-use=code.profclangd
+        '-fprofile-instr-use',
+        # ICC
+        "-prof-use",
+    )
+    return any(option in cflags_nodist for option in pgo_options)
+
+
 _header = 'nP'
 _align = '0n'
 if hasattr(sys, "getobjects"):
index 922e74b441457ab0ada2a58f0d5167d7d91e42eb..671ec2961e7f8f5f3c3619b7380b220082c5e725 100644 (file)
@@ -15,6 +15,10 @@ with imports_under_tool('freeze', 'test'):
 @support.requires_zlib()
 @unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows')
 @support.skip_if_buildbot('not all buildbots have enough space')
+# gh-103053: Skip test if Python is built with Profile Guided Optimization
+# (PGO), since the test is just too slow in this case.
+@unittest.skipIf(support.check_cflags_pgo(),
+                 'test is too slow with PGO')
 class TestFreeze(unittest.TestCase):
 
     @support.requires_resource('cpu') # Building Python is slow
diff --git a/Misc/NEWS.d/next/Tests/2023-09-20-02-32-17.gh-issue-103053.AoUJuK.rst b/Misc/NEWS.d/next/Tests/2023-09-20-02-32-17.gh-issue-103053.AoUJuK.rst
new file mode 100644 (file)
index 0000000..6d67bf2
--- /dev/null
@@ -0,0 +1,4 @@
+Skip test_freeze_simple_script() of test_tools.test_freeze if Python is built
+with ``./configure --enable-optimizations``, which means with Profile Guided
+Optimization (PGO): it just makes the test too slow. The freeze tool is tested
+by many other CIs with other (faster) compiler flags. Patch by Victor Stinner.