Patchwork [080,of,179,tests-refactor] run-tests: move umask into TestRunner.run()

login
register
mail settings
Submitter Gregory Szorc
Date May 2, 2014, 6:38 p.m.
Message ID <8669a3597f7f9c2c9a66.1399055917@vm-ubuntu-main.gateway.sonic.net>
Download mbox | patch
Permalink /patch/4575/
State Accepted
Commit bd70dcb91af67d806c6326d028536826f85f77c2
Headers show

Comments

Gregory Szorc - May 2, 2014, 6:38 p.m.
# HG changeset patch
# User Gregory Szorc <gregory.szorc@gmail.com>
# Date 1398013579 25200
#      Sun Apr 20 10:06:19 2014 -0700
# Branch stable
# Node ID 8669a3597f7f9c2c9a6697ba9820f742b7c4fa75
# Parent  7271d4004ff52e6d6a70f5839c5af953db0fff8c
run-tests: move umask into TestRunner.run()

We now properly restore the umask as well, since run() tries to clean up
after itself.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -1012,22 +1012,24 @@  class TestRunner(object):
         self.abort = [False]
         self._createdfiles = []
 
     def run(self, args):
         """Run the test suite."""
 
         # Be kind and try to clean up after ourselves.
         oldenv = dict(os.environ)
+        oldmask = os.umask(022)
         try:
             self._checktools()
             tests = self.findtests(args)
 
             return self._run(tests)
         finally:
+            os.umask(oldmask)
             os.environ.clear()
             os.environ.update(oldenv)
 
     def _run(self, tests):
         if self.options.random:
             random.shuffle(tests)
         else:
             # keywords for slow tests
@@ -1460,14 +1462,13 @@  class TestRunner(object):
                 print "WARNING: Did not find prerequisite tool: %s " % p
 
 def main(args, runner=None, parser=None):
     runner = runner or TestRunner()
 
     parser = parser or getparser()
     (options, args) = parseargs(args, parser)
     runner.options = options
-    os.umask(022)
 
     return runner.run(args)
 
 if __name__ == '__main__':
     sys.exit(main(sys.argv[1:]))