Fix the "regrtest -s" switch.

This commit is contained in:
Florent Xicluna 2010-04-23 18:10:12 +00:00
parent 64f6c2fcab
commit 1273566cb7
1 changed files with 9 additions and 8 deletions

View File

@ -211,6 +211,8 @@ RESOURCE_NAMES = ('audio', 'curses', 'largefile', 'network', 'bsddb',
'decimal', 'compiler', 'subprocess', 'urlfetch', 'gui', 'decimal', 'compiler', 'subprocess', 'urlfetch', 'gui',
'xpickle') 'xpickle')
TEMPDIR = os.path.abspath(tempfile.gettempdir())
def usage(code, msg=''): def usage(code, msg=''):
print __doc__ print __doc__
@ -381,7 +383,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
found_garbage = [] found_garbage = []
if single: if single:
filename = 'pynexttest' filename = os.path.join(TEMPDIR, 'pynexttest')
try: try:
fp = open(filename, 'r') fp = open(filename, 'r')
next_test = fp.read().strip() next_test = fp.read().strip()
@ -413,7 +415,7 @@ def main(tests=None, testdir=None, verbose=0, quiet=False,
args = [] args = []
# For a partial run, we do not need to clutter the output. # For a partial run, we do not need to clutter the output.
if verbose or not (quiet or tests or args): if verbose or not (quiet or single or tests or args):
# Print basic platform information # Print basic platform information
print "==", platform.python_implementation(), \ print "==", platform.python_implementation(), \
" ".join(sys.version.split()) " ".join(sys.version.split())
@ -1519,18 +1521,17 @@ if __name__ == '__main__':
# to keep the test files in a subfolder. It eases the cleanup of leftover # to keep the test files in a subfolder. It eases the cleanup of leftover
# files using command "make distclean". # files using command "make distclean".
if sysconfig.is_python_build(): if sysconfig.is_python_build():
parent_dir = os.path.join(sysconfig.get_config_var('srcdir'), 'build') TEMPDIR = os.path.join(sysconfig.get_config_var('srcdir'), 'build')
if not os.path.exists(parent_dir): TEMPDIR = os.path.abspath(TEMPDIR)
os.mkdir(parent_dir) if not os.path.exists(TEMPDIR):
else: os.mkdir(TEMPDIR)
parent_dir = os.path.abspath(tempfile.gettempdir())
# Define a writable temp dir that will be used as cwd while running # Define a writable temp dir that will be used as cwd while running
# the tests. The name of the dir includes the pid to allow parallel # the tests. The name of the dir includes the pid to allow parallel
# testing (see the -j option). # testing (see the -j option).
TESTCWD = 'test_python_{}'.format(os.getpid()) TESTCWD = 'test_python_{}'.format(os.getpid())
TESTCWD = os.path.join(parent_dir, TESTCWD) TESTCWD = os.path.join(TEMPDIR, TESTCWD)
# Run the tests in a context manager that temporary changes the CWD to a # Run the tests in a context manager that temporary changes the CWD to a
# temporary and writable directory. If it's not possible to create or # temporary and writable directory. If it's not possible to create or