From 645e503ba58086c7f51eda4d025743f2afc05a2a Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Thu, 20 Jul 2017 17:08:51 +0200 Subject: [PATCH] bpo-30822: Exclude tzdata from regrtest --all (#2775) (#2781) When running the test suite using --use=all / -u all, exclude tzdata since it makes test_datetime too slow (15-20 min on some buildbots) which then times out on some buildbots. -u tzdata must now be enabled explicitly, -u tzdata or -u all,tzdata, to run all test_datetime tests. Fix also regrtest command line parser to allow passing -u extralargefile to run test_zipfile64. Travis CI: remove -tzdata. Replace -u all,-tzdata,-cpu with -u all,-cpu since tzdata is now excluded from -u all. (cherry picked from commit 5b392bbaeb9d9b1db961ecfc7315d8c8662c27f6) --- Lib/test/libregrtest/__init__.py | 5 +++++ Lib/test/regrtest.py | 15 ++++++++++++--- Lib/test/test_regrtest.py | 13 ++++++++++++- .../2017-07-20-14-29-54.bpo-30822.X0wREo.rst | 5 +++++ 4 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 Lib/test/libregrtest/__init__.py create mode 100644 Misc/NEWS.d/next/Tests/2017-07-20-14-29-54.bpo-30822.X0wREo.rst diff --git a/Lib/test/libregrtest/__init__.py b/Lib/test/libregrtest/__init__.py new file mode 100644 index 0000000000..3427b51b60 --- /dev/null +++ b/Lib/test/libregrtest/__init__.py @@ -0,0 +1,5 @@ +# We import importlib *ASAP* in order to test #15386 +import importlib + +from test.libregrtest.cmdline import _parse_args, RESOURCE_NAMES, ALL_RESOURCES +from test.libregrtest.main import main diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py index f9457203c9..c345934583 100755 --- a/Lib/test/regrtest.py +++ b/Lib/test/regrtest.py @@ -207,8 +207,17 @@ CHILD_ERROR = -5 # error in a child process from test import support -RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', - 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui') +ALL_RESOURCES = ('audio', 'curses', 'largefile', 'network', + 'decimal', 'cpu', 'subprocess', 'urlfetch', 'gui') + +# Other resources excluded from --use=all: +# +# - extralagefile (ex: test_zipfile64): really too slow to be enabled +# "by default" +# - tzdata: while needed to validate fully test_datetime, it makes +# test_datetime too slow (15-20 min on some buildbots) and so is disabled by +# default (see bpo-30822). +RESOURCE_NAMES = ALL_RESOURCES + ('extralargefile', 'tzdata') # When tests are run from the Python build directory, it is best practice # to keep the test files in a subfolder. This eases the cleanup of leftover @@ -432,7 +441,7 @@ def _parse_args(args, **kwargs): for a in ns.use: for r in a: if r == 'all': - ns.use_resources[:] = RESOURCE_NAMES + ns.use_resources[:] = ALL_RESOURCES continue if r == 'none': del ns.use_resources[:] diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py index 0eb3f08fe7..dc5899203c 100644 --- a/Lib/test/test_regrtest.py +++ b/Lib/test/test_regrtest.py @@ -192,15 +192,26 @@ class ParseArgsTestCase(unittest.TestCase): with self.subTest(opt=opt): ns = regrtest._parse_args([opt, 'gui,network']) self.assertEqual(ns.use_resources, ['gui', 'network']) + ns = regrtest._parse_args([opt, 'gui,none,network']) self.assertEqual(ns.use_resources, ['network']) - expected = list(regrtest.RESOURCE_NAMES) + + expected = list(regrtest.ALL_RESOURCES) expected.remove('gui') ns = regrtest._parse_args([opt, 'all,-gui']) self.assertEqual(ns.use_resources, expected) self.checkError([opt], 'expected one argument') self.checkError([opt, 'foo'], 'invalid resource') + # all + a resource not part of "all" + ns = regrtest._parse_args([opt, 'all,tzdata']) + self.assertEqual(ns.use_resources, + list(regrtest.ALL_RESOURCES) + ['tzdata']) + + # test another resource which is not part of "all" + ns = regrtest._parse_args([opt, 'extralargefile']) + self.assertEqual(ns.use_resources, ['extralargefile']) + def test_memlimit(self): for opt in '-M', '--memlimit': with self.subTest(opt=opt): diff --git a/Misc/NEWS.d/next/Tests/2017-07-20-14-29-54.bpo-30822.X0wREo.rst b/Misc/NEWS.d/next/Tests/2017-07-20-14-29-54.bpo-30822.X0wREo.rst new file mode 100644 index 0000000000..53557f66fe --- /dev/null +++ b/Misc/NEWS.d/next/Tests/2017-07-20-14-29-54.bpo-30822.X0wREo.rst @@ -0,0 +1,5 @@ +regrtest: Exclude tzdata from regrtest --all. When running the test suite +using --use=all / -u all, exclude tzdata since it makes test_datetime too +slow (15-20 min on some buildbots) which then times out on some buildbots. +Fix also regrtest command line parser to allow passing -u extralargefile to +run test_zipfile64. -- 2.40.0