Bug 903606 - Use mozfile.TemporaryDirectory in cppunittest scripts;r=ted

This commit is contained in:
Dan Minor 2013-08-19 10:02:42 -04:00
parent b1c2b07b0e
commit eaaf70938d
2 changed files with 3 additions and 9 deletions

View File

@ -132,7 +132,7 @@ class RemoteCPPUnitTests(cppunittests.CPPUnitTests):
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):

View File

@ -7,17 +7,11 @@
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
@ -38,7 +32,7 @@ class CPPUnitTests(object):
"""
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)