]> granicus.if.org Git - python/commitdiff
bpo-37707: Exclude expensive unit tests from PGO task (GH-15009) (#15024)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 30 Jul 2019 18:34:33 +0000 (11:34 -0700)
committerNeil Schemenauer <nas-github@arctrix.com>
Tue, 30 Jul 2019 18:34:32 +0000 (11:34 -0700)
Mark some individual tests to skip when --pgo is used.  The tests
marked increase the PGO task time significantly and likely don't
help improve optimization of the final executable.
(cherry picked from commit 52a48e62c6a94577152f9301bbe5f3bc806cfcf1)

Co-authored-by: Neil Schemenauer <nas-github@arctrix.com>
Lib/test/libregrtest/main.py
Lib/test/pickletester.py
Lib/test/support/__init__.py
Lib/test/test_bz2.py
Lib/test/test_itertools.py
Lib/test/test_lzma.py
Lib/test/test_statistics.py
Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst [new file with mode: 0644]

index 2b6607df15dd8e7060c7d4f6907f055337b1a1ce..87278d0c76a2a51c0dfe275728513948c36495cf 100644 (file)
@@ -643,6 +643,7 @@ class Regrtest:
             input("Press any key to continue...")
 
         support.PGO = self.ns.pgo
+        support.PGO_EXTENDED = self.ns.pgo_extended
 
         setup_tests(self.ns)
 
index 2bc99e6becfd0d7ac93506d814eeb0c670cfa8ec..5d402a4711bff6b16e8fdfe7d9fd51a1121b9315 100644 (file)
@@ -2281,6 +2281,7 @@ class AbstractPickleTests(unittest.TestCase):
     FRAME_SIZE_MIN = 4
     FRAME_SIZE_TARGET = 64 * 1024
 
+    @support.skip_if_pgo_task
     def check_frame_opcodes(self, pickled):
         """
         Check the arguments of FRAME opcodes in a protocol 4+ pickle.
@@ -2328,6 +2329,7 @@ class AbstractPickleTests(unittest.TestCase):
         elif frameless_start is not None:
             self.assertLess(pos - frameless_start, self.FRAME_SIZE_MIN)
 
+    @support.skip_if_pgo_task
     def test_framing_many_objects(self):
         obj = list(range(10**5))
         for proto in range(4, pickle.HIGHEST_PROTOCOL + 1):
@@ -2417,6 +2419,7 @@ class AbstractPickleTests(unittest.TestCase):
                                 count_opcode(pickle.FRAME, pickled))
                 self.assertEqual(obj, self.loads(some_frames_pickle))
 
+    @support.skip_if_pgo_task
     def test_framed_write_sizes_with_delayed_writer(self):
         class ChunkAccumulator:
             """Accumulate pickler output in a list of raw chunks."""
index 1ada1f927d9c0be8abb8f6ee6ee4a31ec2800078..b88eb5804a96e907d626f8c1a15e8588a5f43966 100644 (file)
@@ -971,6 +971,10 @@ SAVEDCWD = os.getcwd()
 # useful for PGO
 PGO = False
 
+# Set by libregrtest/main.py if we are running the extended (time consuming)
+# PGO task.  If this is True, PGO is also True.
+PGO_EXTENDED = False
+
 @contextlib.contextmanager
 def temp_dir(path=None, quiet=False):
     """Return a context manager that creates a temporary directory.
@@ -2636,6 +2640,12 @@ def skip_unless_xattr(test):
     msg = "no non-broken extended attribute support"
     return test if ok else unittest.skip(msg)(test)
 
+def skip_if_pgo_task(test):
+    """Skip decorator for tests not run in (non-extended) PGO task"""
+    ok = not PGO or PGO_EXTENDED
+    msg = "Not run for (non-extended) PGO task"
+    return test if ok else unittest.skip(msg)(test)
+
 _bind_nix_socket_error = None
 def skip_unless_bind_unix_socket(test):
     """Decorator for tests requiring a functional bind() for unix sockets."""
index f158b901b9c90ab675115a5aa40af2ae0d5a4d35..eb2f72ee4a5d3bbb552e6337dda5417459f40c95 100644 (file)
@@ -643,6 +643,7 @@ class BZ2CompressorTest(BaseTest):
         data += bz2c.flush()
         self.assertEqual(ext_decompress(data), self.TEXT)
 
+    @support.skip_if_pgo_task
     @bigmemtest(size=_4G + 100, memuse=2)
     def testCompress4G(self, size):
         # "Test BZ2Compressor.compress()/flush() with >4GiB input"
@@ -701,6 +702,7 @@ class BZ2DecompressorTest(BaseTest):
         self.assertRaises(EOFError, bz2d.decompress, b"anything")
         self.assertRaises(EOFError, bz2d.decompress, b"")
 
+    @support.skip_if_pgo_task
     @bigmemtest(size=_4G + 100, memuse=3.3)
     def testDecompress4G(self, size):
         # "Test BZ2Decompressor.decompress() with >4GiB input"
index ea060a98a5eef497e4cc129544c24eadb38842b3..573739fde14c93fba0e5977efaa09531df52cc09 100644 (file)
@@ -2062,6 +2062,7 @@ class RegressionTests(unittest.TestCase):
         self.assertRaises(AssertionError, list, cycle(gen1()))
         self.assertEqual(hist, [0,1])
 
+    @support.skip_if_pgo_task
     def test_long_chain_of_empty_iterables(self):
         # Make sure itertools.chain doesn't run into recursion limits when
         # dealing with long chains of empty iterables. Even with a high
index 3dc2c1e7e3b779e3e54ad598aba15d2a41444dcf..117de0a1b5548b0647ac0cf59aadd2d2004b721b 100644 (file)
@@ -333,6 +333,7 @@ class CompressorDecompressorTestCase(unittest.TestCase):
 
     # Test with inputs larger than 4GiB.
 
+    @support.skip_if_pgo_task
     @bigmemtest(size=_4G + 100, memuse=2)
     def test_compressor_bigmem(self, size):
         lzc = LZMACompressor()
@@ -344,6 +345,7 @@ class CompressorDecompressorTestCase(unittest.TestCase):
         finally:
             ddata = None
 
+    @support.skip_if_pgo_task
     @bigmemtest(size=_4G + 100, memuse=3)
     def test_decompressor_bigmem(self, size):
         lzd = LZMADecompressor()
index ed2f6579b0b9a94bfebd94ff800a17ea6e050736..104718ed7db6c32914a8ec64f0b642627a9527a3 100644 (file)
@@ -14,6 +14,7 @@ import pickle
 import random
 import sys
 import unittest
+from test import support
 
 from decimal import Decimal
 from fractions import Fraction
@@ -2462,6 +2463,7 @@ class TestNormalDist(unittest.TestCase):
         self.assertEqual(X.cdf(float('Inf')), 1.0)
         self.assertTrue(math.isnan(X.cdf(float('NaN'))))
 
+    @support.skip_if_pgo_task
     def test_inv_cdf(self):
         NormalDist = statistics.NormalDist
 
diff --git a/Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst b/Misc/NEWS.d/next/Build/2019-07-29-11-36-16.bpo-37707.Sm-dGk.rst
new file mode 100644 (file)
index 0000000..c0d58ab
--- /dev/null
@@ -0,0 +1,3 @@
+Mark some individual tests to skip when --pgo is used.  The tests marked
+increase the PGO task time significantly and likely don't help improve
+optimization of the final executable.