8000 Add --tempdir option for test run (GH-10322) · python/cpython@f415aa1 · GitHub
[go: up one dir, main page]

Skip to content

Commit f415aa1

Browse files
Add --tempdir option for test run (GH-10322)
(cherry picked from commit 38df97a) Co-authored-by: Steve Dower <steve.dower@microsoft.com>
1 parent 3a600d2 commit f415aa1

File tree

3 files changed

+9
-11
lines changed

3 files changed

+9
-11
lines changed

.azure-pipelines/windows-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ steps:
1717
- script: python.bat -m test.pythoninfo
1818
displayName: 'Display build info'
1919

20-
- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml"
20+
- script: PCbuild\rt.bat -q -uall -u-cpu -rwW --slowest --timeout=1200 -j0 --junit-xml="$(Build.BinariesDirectory)\test-results.xml" --tempdir="$(Build.BinariesDirectory)\test"
2121
displayName: 'Tests'
2222
env:
2323
PREFIX: $(Py_OutDir)\$(arch)

Lib/test/libregrtest/cmdline.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,8 @@ def _create_parser():
271271
group.add_argument('--junit-xml', dest='xmlpath', metavar='FILENAME',
272272
help='writes JUnit-style XML results to the specified '
273273
'file')
274-
274+
group.add_argument('--tempdir', dest='tempdir', metavar='PATH',
275+
help='override the working directory for the test run')
275276
return parser
276277

277278

@@ -383,8 +384,7 @@ def _parse_args(args, **kwargs):
383384
if ns.match_filename:
384385
if ns.match_tests is None:
385386
ns.match_tests = []
386-
filename = os.path.join(support.SAVEDCWD, ns.match_filename)
387-
with open(filename) as fp:
387+
with open(ns.match_filename) as fp:
388388
for line in fp:
389389
ns.match_tests.append(line.strip())
390390

Lib/test/libregrtest/main.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -550,12 +550,12 @@ def save_xml_result(self):
550550

551551
def main(self, tests=None, **kwargs):
552552
global TEMPDIR
553+
self.ns = self.parse_args(kwargs)
553554

554-
if sysconfig.is_python_build():
555-
try:
556-
os.mkdir(TEMPDIR)
557-
except FileExistsError:
558-
pass
555+
if self.ns.tempdir:
556+
TEMPDIR = self.ns.tempdir
557+
558+
os.makedirs(TEMPDIR, exist_ok=True)
559559

560560
# Define a writable temp dir that will be used as cwd while running
561561
# the tests. The name of the dir includes the pid to allow parallel
@@ -571,8 +571,6 @@ def main(self, tests=None, **kwargs):
571571
self._main(tests, kwargs)
572572

573573
def _main(self, tests, kwargs):
574-
self.ns = self.parse_args(kwargs)
575-
576574
if self.ns.huntrleaks:
577575
warmup, repetitions, _ = self.ns.huntrleaks
578576
if warmup < 1 or repetitions < 1:

0 commit comments

Comments
 (0)
0