gh-93353: regrtest supports checking tmp files with -j2 (#93909)

regrtest now also implements checking for leaked temporary files and
directories when using -jN for N >= 2. Use tempfile.mkdtemp() to
create the temporary directory. Skip this check on WASI.
This commit is contained in:
Victor Stinner 2022-06-16 21:48:26 +02:00 committed by GitHub
parent 138db8e48b
commit 4f85cec9e2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 11 deletions

View file

@ -1357,6 +1357,8 @@ class ArgsTestCase(BaseTestCase):
for name in names:
self.assertFalse(os.path.exists(name), name)
@unittest.skipIf(support.is_wasi,
'checking temp files is not implemented on WASI')
def test_leak_tmp_file(self):
code = textwrap.dedent(r"""
import os.path
@ -1369,15 +1371,17 @@ class ArgsTestCase(BaseTestCase):
with open(filename, "wb") as fp:
fp.write(b'content')
""")
testname = self.create_test(code=code)
testnames = [self.create_test(code=code) for _ in range(3)]
output = self.run_tests("--fail-env-changed", "-v", "-j1", testname, exitcode=3)
self.check_executed_tests(output, [testname],
env_changed=[testname],
fail_env_changed=True)
self.assertIn(f"Warning -- {testname} leaked temporary "
f"files (1): mytmpfile",
output)
output = self.run_tests("--fail-env-changed", "-v", "-j2", *testnames, exitcode=3)
self.check_executed_tests(output, testnames,
env_changed=testnames,
fail_env_changed=True,
randomize=True)
for testname in testnames:
self.assertIn(f"Warning -- {testname} leaked temporary "
f"files (1): mytmpfile",
output)
class TestUtils(unittest.TestCase):