Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 81cd1bd

Browse filesBrowse files
authored
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.
1 parent 3e3a7da commit 81cd1bd
Copy full SHA for 81cd1bd

File tree

5 files changed

+36
-10
lines changed
Filter options

5 files changed

+36
-10
lines changed

‎Lib/test/libregrtest/utils.py

Copy file name to clipboardExpand all lines: Lib/test/libregrtest/utils.py
+2-10Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,16 +310,8 @@ def get_build_info():
310310
elif '-flto' in ldflags_nodist:
311311
optimizations.append('LTO')
312312

313-
# --enable-optimizations
314-
pgo_options = (
315-
# GCC
316-
'-fprofile-use',
317-
# clang: -fprofile-instr-use=code.profclangd
318-
'-fprofile-instr-use',
319-
# ICC
320-
"-prof-use",
321-
)
322-
if any(option in cflags_nodist for option in pgo_options):
313+
if support.check_cflags_pgo():
314+
# PGO (--enable-optimizations)
323315
optimizations.append('PGO')
324316
if optimizations:
325317
build.append('+'.join(optimizations))

‎Lib/test/pythoninfo.py

Copy file name to clipboardExpand all lines: Lib/test/pythoninfo.py
+11Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -956,6 +956,16 @@ def collect_tempfile(info_add):
956956

957957
info_add('tempfile.gettempdir', tempfile.gettempdir())
958958

959+
960+
def collect_libregrtest_utils(info_add):
961+
try:
962+
from test.libregrtest import utils
963+
except ImportError:
964+
return
965+
966+
info_add('libregrtests.build_info', ' '.join(utils.get_build_info()))
967+
968+
959969
def collect_info(info):
960970
error = False
961971
info_add = info.add
@@ -995,6 +1005,7 @@ def collect_info(info):
9951005
collect_tkinter,
9961006
collect_windows,
9971007
collect_zlib,
1008+
collect_libregrtest_utils,
9981009

9991010
# Collecting from tests should be last as they have side effects.
10001011
collect_test_socket,

‎Lib/test/support/__init__.py

Copy file name to clipboardExpand all lines: Lib/test/support/__init__.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -773,6 +773,21 @@ def python_is_optimized():
773773
return final_opt not in ('', '-O0', '-Og')
774774

775775

776+
def check_cflags_pgo():
777+
# Check if Python was built with ./configure --enable-optimizations:
778+
# with Profile Guided Optimization (PGO).
779+
cflags_nodist = sysconfig.get_config_var('PY_CFLAGS_NODIST') or ''
780+
pgo_options = (
781+
# GCC
782+
'-fprofile-use',
783+
# clang: -fprofile-instr-use=code.profclangd
784+
'-fprofile-instr-use',
785+
# ICC
786+
"-prof-use",
787+
)
788+
return any(option in cflags_nodist for option in pgo_options)
789+
790+
776791
_header = 'nP'
777792
_align = '0n'
778793
_vheader = _header + 'n'

‎Lib/test/test_tools/test_freeze.py

Copy file name to clipboardExpand all lines: Lib/test/test_tools/test_freeze.py
+4Lines 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
+4Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.