diff options
author | Victor Stinner <vstinner@python.org> | 2023-09-20 15:45:23 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-20 15:45:23 (GMT) |
commit | 8c7fadb9bf86b4be0aad70a121b4d487d7729a64 (patch) | |
tree | 6cb7fd14580f42fb719ef055887ffc8284ecce5d | |
parent | 336dbe56b292f26e14e70975401a3a954fcbd76b (diff) | |
download | cpython-8c7fadb9bf86b4be0aad70a121b4d487d7729a64.zip cpython-8c7fadb9bf86b4be0aad70a121b4d487d7729a64.tar.gz cpython-8c7fadb9bf86b4be0aad70a121b4d487d7729a64.tar.bz2 |
[3.11] gh-103053: Skip test_freeze_simple_script() on PGO build (#109591) (#109616)
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)
-rw-r--r-- | Lib/test/libregrtest/utils.py | 12 | ||||
-rw-r--r-- | Lib/test/pythoninfo.py | 10 | ||||
-rw-r--r-- | Lib/test/support/__init__.py | 15 | ||||
-rw-r--r-- | Lib/test/test_tools/test_freeze.py | 4 | ||||
-rw-r--r-- | Misc/NEWS.d/next/Tests/2023-09-20-02-32-17.gh-issue-103053.AoUJuK.rst | 4 |
5 files changed, 35 insertions, 10 deletions
diff --git a/Lib/test/libregrtest/utils.py b/Lib/test/libregrtest/utils.py index 751dc04..49f3a23 100644 --- a/Lib/test/libregrtest/utils.py +++ b/Lib/test/libregrtest/utils.py @@ -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)) diff --git a/Lib/test/pythoninfo.py b/Lib/test/pythoninfo.py index 7a9c01b..69d2fc0 100644 --- a/Lib/test/pythoninfo.py +++ b/Lib/test/pythoninfo.py @@ -875,6 +875,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 @@ -912,6 +921,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, diff --git a/Lib/test/support/__init__.py b/Lib/test/support/__init__.py index 05b3375..b4fa727 100644 --- a/Lib/test/support/__init__.py +++ b/Lib/test/support/__init__.py @@ -765,6 +765,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"): diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py index 922e74b..671ec29 100644 --- a/Lib/test/test_tools/test_freeze.py +++ b/Lib/test/test_tools/test_freeze.py @@ -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 index 0000000..6d67bf2 --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2023-09-20-02-32-17.gh-issue-103053.AoUJuK.rst @@ -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. |