This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Add some test execution environment protection to regrtest
Type: enhancement Stage: resolved
Components: Tests Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: r.david.murray Nosy List: ezio.melotti, pitrou, r.david.murray
Priority: normal Keywords: patch

Created on 2009-10-04 23:08 by r.david.murray, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
regrtest_guards.patch r.david.murray, 2009-10-05 16:07
refactored_environment_checking.patch r.david.murray, 2009-10-14 13:26
Messages (12)
msg93566 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-04 23:08
One of the failures when regrtest is run with a read-only Lib results
from test_runpy modifying sys.argv.  Antoine also found cases where
tests modified os.environ in issue 7055.  It seems useful to have
regrtest fix these kinds of environment corruptions when it can, but to
also issue warnings so that the tests in questions can be fixed.  In
some cases the warnings might also reveal bugs in the code being tested,
if the code being tested does a modification it should not be doing.

Attached is a patch that adds save/restore for os.environ and sys.argv,
with warning messages.
msg93567 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-05 00:05
Or should regrtest convert these into test failures for reporting purposes?
msg93607 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-05 16:05
Apart from the comments I made on IRC, I think it would be nice to have
this patch in 2.6 and 3.1 as well. While not technically a bug fix, it
is innocuous for users and certainly helps finding problems.
msg93608 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-05 16:07
Updated patch based on Antoine's feedback on IRC.  Removes a mislaid
'not quiet' and restores argv using argv[:] = saved_argv.

I agree about putting it into 2.6/3.1.  We could also claim that it is
fixing a bug in the running of the tests :)  I suspect it might make the
buildbots more stable, for example.
msg93730 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-07 23:58
Committed to trunk in r75255, py3k in r75279, and 3.1 in r75280. 
Leaving open until 2.6 is unfrozen and I can commit it there as well.
msg93732 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2009-10-08 01:11
The cwd should also be checked/restored to avoid problems like #7066.
msg93880 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-11 22:49
I've refactored the code and added more checks (cwd, all three stdio
attributes).  Patch attached.  I'm not done with this because I want to
make the reporting more visible.
msg93885 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-12 01:26
Here is a finished version of the refactoring patch.  It introduces a
new category in the list of test statuses at in the summary to list the
tests that have changed the execution environment.  This patch makes it
easy to add additional things to check and restore, and I've added
'sys.path' checking.
msg93982 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-14 13:25
Here is an updated patch that doesn't break -j.
msg93983 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2009-10-14 13:33
Looks good to me. Not sure it should be backported though, the patch has
become really sizeable.
msg93984 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-14 13:36
I agree about not backporting the new patch.
msg94588 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2009-10-27 23:31
Enhanced patch applied in r75400, and further enhanced by Nick Coghlan
in r75456, r75457, and r75466.  Ported to py3k by Nick in r75493, with a
little cleanup in r75504.
History
Date User Action Args
2022-04-11 14:56:53adminsetgithub: 51307
2009-10-27 23:31:56r.david.murraysetstatus: open -> closed

messages: + msg94588
2009-10-14 13:36:21r.david.murraysetmessages: + msg93984
2009-10-14 13:33:59pitrousetmessages: + msg93983
2009-10-14 13:26:02r.david.murraysetfiles: + refactored_environment_checking.patch

messages: + msg93982
2009-10-14 13:24:29r.david.murraysetfiles: - refactored_environment_checking.patch
2009-10-12 01:30:26r.david.murraysetfiles: - refactored_environment_checking.patch
2009-10-12 01:26:12r.david.murraysetfiles: + refactored_environment_checking.patch

messages: + msg93885
2009-10-11 22:49:29r.david.murraysetfiles: + refactored_environment_checking.patch

messages: + msg93880
2009-10-08 01:11:09ezio.melottisetnosy: + ezio.melotti
messages: + msg93732
2009-10-08 00:00:20r.david.murraysetfiles: - regrtest_guards.patch
2009-10-07 23:58:44r.david.murraysetassignee: r.david.murray
resolution: accepted
messages: + msg93730
stage: patch review -> resolved
2009-10-05 16:07:44r.david.murraysetfiles: + regrtest_guards.patch

messages: + msg93608
2009-10-05 16:05:14pitrousetnosy: + pitrou

messages: + msg93607
versions: + Python 2.6, Python 3.1
2009-10-05 00:05:28r.david.murraysetmessages: + msg93567
2009-10-04 23:08:32r.david.murraycreate