Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(4)

Side by Side Diff: Lib/test/libregrtest/setup.py

Issue 26295: Random failures when running test suite in parallel (-m test -j0) caused by test_regrtest
Patch Set: Created 3 years, 11 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/__init__.py ('k') | Lib/test/test_regrtest.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 import atexit 1 import atexit
2 import faulthandler 2 import faulthandler
3 import os 3 import os
4 import signal 4 import signal
5 import sys 5 import sys
6 import unittest 6 import unittest
7 from test import support 7 from test import support
8 try: 8 try:
9 import gc 9 import gc
10 except ImportError: 10 except ImportError:
(...skipping 10 matching lines...) Expand all
21 signals = [] 21 signals = []
22 if hasattr(signal, 'SIGALRM'): 22 if hasattr(signal, 'SIGALRM'):
23 signals.append(signal.SIGALRM) 23 signals.append(signal.SIGALRM)
24 if hasattr(signal, 'SIGUSR1'): 24 if hasattr(signal, 'SIGUSR1'):
25 signals.append(signal.SIGUSR1) 25 signals.append(signal.SIGUSR1)
26 for signum in signals: 26 for signum in signals:
27 faulthandler.register(signum, chain=True) 27 faulthandler.register(signum, chain=True)
28 28
29 replace_stdout() 29 replace_stdout()
30 support.record_original_stdout(sys.stdout) 30 support.record_original_stdout(sys.stdout)
31
32 if ns.testdir:
33 sys.path.insert(0, os.path.dirname(ns.testdir))
31 34
32 # Some times __path__ and __file__ are not absolute (e.g. while running from 35 # Some times __path__ and __file__ are not absolute (e.g. while running from
33 # Lib/) and, if we change the CWD to run the tests in a temporary dir, some 36 # Lib/) and, if we change the CWD to run the tests in a temporary dir, some
34 # imports might fail. This affects only the modules imported before os.chdi r(). 37 # imports might fail. This affects only the modules imported before os.chdi r().
35 # These modules are searched first in sys.path[0] (so '' -- the CWD) and if 38 # These modules are searched first in sys.path[0] (so '' -- the CWD) and if
36 # they are found in the CWD their __file__ and __path__ will be relative (th is 39 # they are found in the CWD their __file__ and __path__ will be relative (th is
37 # happens before the chdir). All the modules imported after the chdir, are 40 # happens before the chdir). All the modules imported after the chdir, are
38 # not found in the CWD, and since the other paths in sys.path[1:] are absolu te 41 # not found in the CWD, and since the other paths in sys.path[1:] are absolu te
39 # (site.py absolutize them), the __file__ and __path__ will be absolute too. 42 # (site.py absolutize them), the __file__ and __path__ will be absolute too.
40 # Therefore it is necessary to absolutize manually the __file__ and __path__ of 43 # Therefore it is necessary to absolutize manually the __file__ and __path__ of
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 sys.stdout = open(stdout.fileno(), 'w', 110 sys.stdout = open(stdout.fileno(), 'w',
108 encoding=stdout.encoding, 111 encoding=stdout.encoding,
109 errors="backslashreplace", 112 errors="backslashreplace",
110 closefd=False, 113 closefd=False,
111 newline='\n') 114 newline='\n')
112 115
113 def restore_stdout(): 116 def restore_stdout():
114 sys.stdout.close() 117 sys.stdout.close()
115 sys.stdout = stdout 118 sys.stdout = stdout
116 atexit.register(restore_stdout) 119 atexit.register(restore_stdout)
OLDNEW
« no previous file with comments | « Lib/test/__init__.py ('k') | Lib/test/test_regrtest.py » ('j') | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+