Skip to content

Commit dc70d30

Browse files
authored
[3.12] gh-103053: Skip test_freeze_simple_script() on PGO build (#109591) (#109614)
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 81cd1bd)
1 parent 5ba9d2b commit dc70d30

File tree

5 files changed

+35
-10
lines changed

5 files changed

+35
-10
lines changed

Lib/test/libregrtest/utils.py

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -259,16 +259,8 @@ def get_build_info():
259259
elif '-flto' in ldflags_nodist:
260260
optimizations.append('LTO')
261261

262-
# --enable-optimizations
263-
pgo_options = (
264-
# GCC
265-
'-fprofile-use',
266-
# clang: -fprofile-instr-use=code.profclangd
267-
'-fprofile-instr-use',
268-
# ICC
269-
"-prof-use",
270-
)
271-
if any(option in cflags_nodist for option in pgo_options):
262+
if support.check_cflags_pgo():
263+
# PGO (--enable-optimizations)
272264
optimizations.append('PGO')
273265
if optimizations:
274266
build.append('+'.join(optimizations))

Lib/test/pythoninfo.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,15 @@ def collect_fips(info_add):
867867
pass
868868

869869

870+
def collect_libregrtest_utils(info_add):
871+
try:
872+
from test.libregrtest import utils
873+
except ImportError:
874+
return
875+
876+
info_add('libregrtests.build_info', ' '.join(utils.get_build_info()))
877+
878+
870879
def collect_info(info):
871880
error = False
872881
info_add = info.add
@@ -904,6 +913,7 @@ def collect_info(info):
904913
collect_tkinter,
905914
collect_windows,
906915
collect_zlib,
916+
collect_libregrtest_utils,
907917

908918
# Collecting from tests should be last as they have side effects.
909919
collect_test_socket,

Lib/test/support/__init__.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -781,6 +781,21 @@ def python_is_optimized():
781781
return final_opt not in ('', '-O0', '-Og')
782782

783783

784+
def check_cflags_pgo():
785+
# Check if Python was built with ./configure --enable-optimizations:
786+
# with Profile Guided Optimization (PGO).
787+
cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or ''
788+
pgo_options = (
789+
# GCC
790+
'-fprofile-use',
791+
# clang: -fprofile-instr-use=code.profclangd
792+
'-fprofile-instr-use',
793+
# ICC
794+
"-prof-use",
795+
)
796+
return any(option in cflags_nodist for option in pgo_options)
797+
798+
784799
_header = 'nP'
785800
_align = '0n'
786801
if hasattr(sys, "getobjects"):

Lib/test/test_tools/test_freeze.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
@support.requires_zlib()
1616
@unittest.skipIf(sys.platform.startswith('win'), 'not supported on Windows')
1717
@support.skip_if_buildbot('not all buildbots have enough space')
18+
# gh-103053: Skip test if Python is built with Profile Guided Optimization
19+
# (PGO), since the test is just too slow in this case.
20+
@unittest.skipIf(support.check_cflags_pgo(),
21+
'test is too slow with PGO')
1822
class TestFreeze(unittest.TestCase):
1923

2024
@support.requires_resource('cpu') # Building Python is slow
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Skip test_freeze_simple_script() of test_tools.test_freeze if Python is built
2+
with ``./configure --enable-optimizations``, which means with Profile Guided
3+
Optimization (PGO): it just makes the test too slow. The freeze tool is tested
4+
by many other CIs with other (faster) compiler flags. Patch by Victor Stinner.

0 commit comments

Comments
 (0)