Bug 903606 - Use mozfile.TemporaryDirectory in cppunittest scripts;r=ted
authorDan Minor <dminor@mozilla.com>
Mon, 19 Aug 2013 10:02:42 -0400
changeset 156031 18fbb6afc9d42faaca1727dde54c19d00717ce48
parent 156030 2e1710495bd9f31109899d08e8353da809c249a6
child 156032 de5b7c7741e19b63bb65b19bcb385a7e9e40a9e6
push id2961
push userlsblakk@mozilla.com
push dateMon, 28 Oct 2013 21:59:28 +0000
treeherdermozilla-beta@73ef4f13486f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted
bugs903606
milestone26.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 903606 - Use mozfile.TemporaryDirectory in cppunittest scripts;r=ted
testing/remotecppunittests.py
testing/runcppunittests.py
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -127,17 +127,17 @@ class RemoteCPPUnitTests(cppunittests.CP
         """
         basename = os.path.basename(prog)
         remote_bin = posixpath.join(self.remote_bin_dir, basename)
         log.info("Running test %s", basename)
         buf = StringIO.StringIO()
         returncode = self.device.shell([remote_bin], buf, env=env, cwd=self.remote_home_dir,
                                        timeout=cppunittests.CPPUnitTests.TEST_PROC_TIMEOUT)
         print >> sys.stdout, buf.getvalue()
-        with cppunittests.TemporaryDirectory() as tempdir:
+        with mozfile.TemporaryDirectory() as tempdir:
             self.device.getDirectory(self.remote_home_dir, tempdir)
             if mozcrash.check_for_crashes(tempdir, symbols_path,
                                           test_name=basename):
                 log.testFail("%s | test crashed", basename)
                 return False
         result = returncode == 0
         if not result:
             log.testFail("%s | test failed with return code %s",
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -2,27 +2,21 @@
 #
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 from __future__ import with_statement
 import sys, os, tempfile, shutil
 from optparse import OptionParser
-import mozprocess, mozinfo, mozlog, mozcrash
+import mozprocess, mozinfo, mozlog, mozcrash, mozfile
 from contextlib import contextmanager
 
 log = mozlog.getLogger('cppunittests')
 
-@contextmanager
-def TemporaryDirectory():
-    tempdir = tempfile.mkdtemp()
-    yield tempdir
-    shutil.rmtree(tempdir)
-
 class CPPUnitTests(object):
     # Time (seconds) to wait for test process to complete
     TEST_PROC_TIMEOUT = 1200
     # Time (seconds) in which process will be killed if it produces no output.
     TEST_PROC_NO_OUTPUT_TIMEOUT = 300
 
     def run_one_test(self, prog, env, symbols_path=None):
         """
@@ -33,17 +27,17 @@ class CPPUnitTests(object):
         * env: The environment to use for running the program.
         * symbols_path: A path to a directory containing Breakpad-formatted
                         symbol files for producing stack traces on crash.
 
         Return True if the program exits with a zero status, False otherwise.
         """
         basename = os.path.basename(prog)
         log.info("Running test %s", basename)
-        with TemporaryDirectory() as tempdir:
+        with mozfile.TemporaryDirectory() as tempdir:
             proc = mozprocess.ProcessHandler([prog],
                                              cwd=tempdir,
                                              env=env)
             #TODO: After bug 811320 is fixed, don't let .run() kill the process,
             # instead use a timeout in .wait() and then kill to get a stack.
             proc.run(timeout=CPPUnitTests.TEST_PROC_TIMEOUT,
                      outputTimeout=CPPUnitTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
             proc.wait()