[Python-checkins] Add --tempdir option for test run (GH-10322)
Miss Islington (bot)
webhook-mailer at python.org
Sat Nov 17 07:31:52 EST 2018
https://github.com/python/cpython/commit/f415aa1eef091db099a661a187646b1a76878487
commit: f415aa1eef091db099a661a187646b1a76878487
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2018-11-17T04:31:47-08:00
summary:
Add --tempdir option for test run (GH-10322)
(cherry picked from commit 38df97a03c5102e717a110ab69bff8e5c9ebfd08)
Co-authored-by: Steve Dower <steve.dower at microsoft.com>
files:
M .azure-pipelines/windows-steps.yml
M Lib/test/libregrtest/cmdline.py
M Lib/test/libregrtest/main.py
diff --git a/.azure-pipelines/windows-steps.yml b/.azure-pipelines/windows-steps.yml
index d8d5f1753a07..c3175841a9b8 100644
--- a/.azure-pipelines/windows-steps.yml
+++ b/.azure-pipelines/windows-steps.yml
@@ -17,7 +17,7 @@ steps:
- script: python.bat -m test.pythoninfo
displayName: 'Display build info'
-- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml"
+- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml" --tempdir="$(Build.BinariesDirectory)\test"
displayName: 'Tests'
env:
PREFIX: $(Py_OutDir)\$(arch)
diff --git a/Lib/test/libregrtest/cmdline.py b/Lib/test/libregrtest/cmdline.py
index 2af839a182db..c08491fc0462 100644
--- a/Lib/test/libregrtest/cmdline.py
+++ b/Lib/test/libregrtest/cmdline.py
@@ -271,7 +271,8 @@ def _create_parser():
group.add_argument('--junit-xml', dest='xmlpath', metavar='FILENAME',
help='writes JUnit-style XML results to the specified '
'file')
-
+ group.add_argument('--tempdir', dest='tempdir', metavar='PATH',
+ help='override the working directory for the test run')
return parser
@@ -383,8 +384,7 @@ def _parse_args(args, **kwargs):
if ns.match_filename:
if ns.match_tests is None:
ns.match_tests = []
- filename = os.path.join(support.SAVEDCWD, ns.match_filename)
- with open(filename) as fp:
+ with open(ns.match_filename) as fp:
for line in fp:
ns.match_tests.append(line.strip())
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index b491a08c2424..1438966d4a50 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -550,12 +550,12 @@ def save_xml_result(self):
def main(self, tests=None, **kwargs):
global TEMPDIR
+ self.ns = self.parse_args(kwargs)
- if sysconfig.is_python_build():
- try:
- os.mkdir(TEMPDIR)
- except FileExistsError:
- pass
+ if self.ns.tempdir:
+ TEMPDIR = self.ns.tempdir
+
+ os.makedirs(TEMPDIR, exist_ok=True)
# 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
@@ -571,8 +571,6 @@ def main(self, tests=None, **kwargs):
self._main(tests, kwargs)
def _main(self, tests, kwargs):
- self.ns = self.parse_args(kwargs)
-
if self.ns.huntrleaks:
warmup, repetitions, _ = self.ns.huntrleaks
if warmup < 1 or repetitions < 1:
More information about the Python-checkins
mailing list