New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test.regrtest should complain if a test doesn't remove temporary files #66584
Comments
A change in test_glob of issue bpo-13968 started to fail because a previous test created temporary files but didn't remove them. test.regrtest should at least emit a warning if the temporary directory used to run tests is not empty before removing it. |
Here is a patch. It warns if new files or directories are left after test run in current directory and removes those of them which starts with TESTFN (i.e. TESTFN_UNICODE, TESTFN + "2", TESTFN + ".py" and other names used in tests). |
I would prefer to fix tests instead of trying to remove arbitrary files. I'm not sure that "fn.startswith(support.TESTFN)" check is safe enough. Maybe we should not remove TESTFN neither. You are supposed to be able to run tests without regrtest. |
I ran the test suite with the patch applied: 7 tests altered the execution environment: I will try to investigate these warnings. |
This allow other tests which leaks the same file to be reported too. support.TESTFN contains process ID so it is unique enough. |
Run tests with the -vv option. |
fix_tests.patch: Fix the 7 tests which create files without removing them. 4 tests (test_imp, test_pdb, test_source_encoding and test_support) create a __pycache__ directory. Maybe this directory should be ignored by regrtest? |
New changeset 8cf8bff3569e by Victor Stinner in branch '3.4': |
How about regrtest_warn_lost_files.patch? |
I don't understand your answer. The "fn.startswith(support.TESTFN)" test is not used in get_files(). If I understood correctly, your patch changes two things:
I don't understand why you want to remove more files than before. You may open a different issue, or at least explain the rationale. I never see any forgotten test file after running tests, so I don't see why you are worried because of them. And with your first patch, we will now noticed forgotten files, so we can just fix tests. |
I thought it would be good idea slightly extend this cleanup while we are Well, here is a patch which removes only TESTFN. It is still improved, uses You can just drop cleanup code at all if you prefer. All is good to me.
This is because regrtest creates temporary directory and goes to it. But when
But we will noticed only one about test at the time if several tests forgot |
What about this issue? |
Victor? |
regrtest_warn_lost_files2.patch looks good to me. I just ran the test suite with "./python -m test -j0 -rW" on Linux, I didn't get any warning. When I modified test_os to create a file "x", it was noticed by your patch. Go ahead. |
New changeset f40984e7ceea by Serhiy Storchaka in branch '2.7': New changeset 05e6bab4db8f by Serhiy Storchaka in branch '3.4': New changeset bed806c9eb4c by Serhiy Storchaka in branch 'default': |
New changeset 207db4338706 by Victor Stinner in branch '2.7': |
New changeset fb5c3528d0d7 by Victor Stinner in branch '2.7': |
New changeset c5c31adbefeb by Victor Stinner in branch '2.7': |
New changeset 33e48141d83f by Victor Stinner in branch '2.7': |
On Windows, test_idle modifies os.environ: TCL_xxx and TIX_xxx (sorry |
New changeset 6ef2cacec2e9 by Victor Stinner in branch '2.7': |
Thank you for fixing backported patch and tests Victor. |
Serhiy Storchaka added the comment:
No problem, thanks for your enhancement of regrtest ;-) I proposed the |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: