summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'patches/22_all_tests_environment.patch')
-rw-r--r--patches/22_all_tests_environment.patch71
1 files changed, 35 insertions, 36 deletions
diff --git a/patches/22_all_tests_environment.patch b/patches/22_all_tests_environment.patch
index 11a5f22..5f8d80d 100644
--- a/patches/22_all_tests_environment.patch
+++ b/patches/22_all_tests_environment.patch
@@ -2,7 +2,7 @@ https://bugs.python.org/issue1674555
--- Lib/site.py
+++ Lib/site.py
-@@ -544,8 +544,12 @@
+@@ -546,8 +546,12 @@
known_paths = venv(known_paths)
if ENABLE_USER_SITE is None:
ENABLE_USER_SITE = check_enableusersite()
@@ -27,33 +27,33 @@ https://bugs.python.org/issue1674555
try:
import threading
-@@ -432,7 +433,6 @@
+@@ -434,7 +435,6 @@
subprocess exits, its return code, stdout and stderr are returned as a
3-tuple.
"""
- from subprocess import Popen, PIPE
base_cmd = ([sys.executable] + support.args_from_interpreter_flags() +
['-X', 'faulthandler', '-m', 'test.regrtest'])
-
-@@ -643,6 +643,56 @@
+ # required to spawn a new process with PGO flag on/off
+@@ -657,9 +657,62 @@
support.use_resources = ns.use_resources
save_modules = sys.modules.keys()
-+ opt_args = support.args_from_interpreter_flags()
-+ base_cmd = [sys.executable] + opt_args
-+ base_cmd += ['-X', 'faulthandler', '-m', 'test.regrtest']
-+ debug_output_pat = re.compile(r"\[\d+ refs, \d+ blocks\]$")
-+
+ def _runtest(test, verbose, quiet, huntrleaks=False, use_resources=None,
+ output_on_failure=False, failfast=False, match_tests=None,
-+ timeout=None):
++ timeout=None, *, pgo=False):
+ if test == "test_site":
++ base_cmd = ([sys.executable] + support.args_from_interpreter_flags() +
++ ['-X', 'faulthandler', '-m', 'test.regrtest'])
++ # required to spawn a new process with PGO flag on/off
++ if pgo:
++ base_cmd = base_cmd + ['--pgo']
+ slaveargs = ((test, verbose, quiet),
+ dict(huntrleaks=huntrleaks,
+ use_resources=use_resources,
+ output_on_failure=output_on_failure,
+ timeout=timeout, failfast=failfast,
-+ match_tests=match_tests))
++ match_tests=match_tests, pgo=pgo))
+ env = os.environ.copy()
+ try:
+ del env["_PYTHONNOSITEPACKAGES"]
@@ -63,23 +63,26 @@ https://bugs.python.org/issue1674555
+ stdout=PIPE, stderr=PIPE,
+ universal_newlines=True,
+ close_fds=(os.name != 'nt'),
++ cwd=support.SAVEDCWD,
+ env=env)
+ stdout, stderr = popen.communicate()
+ retcode = popen.wait()
-+ # Strip last refcount output line if it exists, since it
-+ # comes from the shutdown of the interpreter in the subcommand.
-+ stderr = debug_output_pat.sub("", stderr)
+ stdout, _, result = stdout.strip().rpartition("\n")
+ if retcode != 0:
-+ result = (CHILD_ERROR, "Exit code %s" % retcode)
++ result = (CHILD_ERROR, None)
+ else:
++ if not result:
++ return (None, None)
+ result = json.loads(result)
++ stdout = stdout.rstrip()
++ stderr = stderr.rstrip()
+ if stdout:
+ print(stdout)
-+ if stderr:
++ if stderr and not pgo:
+ print(stderr, file=sys.stderr)
++ sys.stdout.flush()
++ sys.stderr.flush()
+ if result[0] == INTERRUPTED:
-+ assert result[1] == 'KeyboardInterrupt'
+ raise KeyboardInterrupt
+ return result
+ else:
@@ -87,20 +90,16 @@ https://bugs.python.org/issue1674555
+ use_resources=use_resources,
+ output_on_failure=output_on_failure,
+ failfast=failfast, match_tests=match_tests,
-+ timeout=timeout)
++ timeout=timeout, pgo=pgo)
+
def accumulate_result(test, result):
ok, test_time = result
- test_times.append((test_time, test))
-@@ -680,7 +730,6 @@
- print("Multiprocess option requires thread support")
- sys.exit(2)
- from queue import Queue
-- debug_output_pat = re.compile(r"\[\d+ refs, \d+ blocks\]$")
- output = Queue()
- pending = MultiprocessTests(tests)
- def work():
-@@ -752,15 +801,15 @@
+- if ok not in (CHILD_ERROR, INTERRUPTED):
++ if ok not in (None, CHILD_ERROR, INTERRUPTED):
+ test_times.append((test_time, test))
+ if ok == PASSED:
+ good.append(test)
+@@ -773,15 +826,15 @@
if ns.trace:
# If we're tracing code coverage, then we don't exit with status
# if on a false return value from main.
@@ -113,27 +112,27 @@ https://bugs.python.org/issue1674555
- ns.huntrleaks,
- output_on_failure=ns.verbose3,
- timeout=ns.timeout, failfast=ns.failfast,
-- match_tests=ns.match_tests)
+- match_tests=ns.match_tests, pgo=ns.pgo)
+ result = _runtest(test, ns.verbose, ns.quiet,
+ ns.huntrleaks,
+ output_on_failure=ns.verbose3,
+ timeout=ns.timeout, failfast=ns.failfast,
-+ match_tests=ns.match_tests)
++ match_tests=ns.match_tests, pgo=ns.pgo)
accumulate_result(test, result)
except KeyboardInterrupt:
interrupted = True
-@@ -813,8 +862,8 @@
+@@ -835,8 +888,8 @@
sys.stdout.flush()
try:
ns.verbose = True
- ok = runtest(test, True, ns.quiet, ns.huntrleaks,
-- timeout=ns.timeout)
+- timeout=ns.timeout, pgo=ns.pgo)
+ ok = _runtest(test, True, ns.quiet, ns.huntrleaks,
-+ timeout=ns.timeout)
++ timeout=ns.timeout, pgo=ns.pgo)
except KeyboardInterrupt:
# print a newline separate from the ^C
print()
-@@ -1236,8 +1285,9 @@
+@@ -1260,8 +1313,9 @@
for name, get, restore in self.resource_info():
current = get()
original = saved_values.pop(name)
@@ -144,7 +143,7 @@ https://bugs.python.org/issue1674555
+ if current != original and self.testname != "test_site":
self.changed = True
restore(original)
- if not self.quiet:
+ if not self.quiet and not self.pgo:
--- Lib/test/test_site.py
+++ Lib/test/test_site.py
@@ -8,6 +8,7 @@
@@ -180,7 +179,7 @@ https://bugs.python.org/issue1674555
stdout, stderr = popen.communicate()
--- Makefile.pre.in
+++ Makefile.pre.in
-@@ -979,7 +979,7 @@
+@@ -994,7 +994,7 @@
######################################################################
TESTOPTS= $(EXTRATESTOPTS)