Issue 7058: Add some test execution environment protection to regrtest (original) (raw)

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:53 admin set github: 51307
2009-10-27 23:31:56 r.david.murray set status: open -> closedmessages: +
2009-10-14 13:36:21 r.david.murray set messages: +
2009-10-14 13:33:59 pitrou set messages: +
2009-10-14 13:26:02 r.david.murray set files: + refactored_environment_checking.patchmessages: +
2009-10-14 13:24:29 r.david.murray set files: - refactored_environment_checking.patch
2009-10-12 01:30:26 r.david.murray set files: - refactored_environment_checking.patch
2009-10-12 01:26:12 r.david.murray set files: + refactored_environment_checking.patchmessages: +
2009-10-11 22:49:29 r.david.murray set files: + refactored_environment_checking.patchmessages: +
2009-10-08 01:11:09 ezio.melotti set nosy: + ezio.melottimessages: +
2009-10-08 00:00:20 r.david.murray set files: - regrtest_guards.patch
2009-10-07 23:58:44 r.david.murray set assignee: r.david.murrayresolution: acceptedmessages: + stage: patch review -> resolved
2009-10-05 16:07:44 r.david.murray set files: + regrtest_guards.patchmessages: +
2009-10-05 16:05:14 pitrou set nosy: + pitroumessages: + versions: + Python 2.6, Python 3.1
2009-10-05 00:05:28 r.david.murray set messages: +
2009-10-04 23:08:32 r.david.murray create