Bug 904574 - Make gtests log output after crashes compatible with TBPL; r=BenWa

--HG--
extra : rebase_source : 8162af561b3a8df81463b3aec733ac6cff55125a
This commit is contained in:
Ed Morley 2013-08-13 15:52:55 +01:00
parent f4cc91c2a9
commit 04d190fd50

View File

@ -10,7 +10,7 @@ from optparse import OptionParser
import mozprocess, mozinfo, mozlog, mozcrash import mozprocess, mozinfo, mozlog, mozcrash
from contextlib import contextmanager from contextlib import contextmanager
log = mozlog.getLogger('gtests') log = mozlog.getLogger('gtest')
class GTests(object): class GTests(object):
# Time (seconds) to wait for test process to complete # Time (seconds) to wait for test process to complete
@ -32,8 +32,7 @@ class GTests(object):
""" """
self.xre_path = xre_path self.xre_path = xre_path
env = self.build_environment() env = self.build_environment()
basename = os.path.basename(prog) log.info("Running gtest")
log.info("Running test %s", basename)
proc = mozprocess.ProcessHandler([prog, "-unittest"], proc = mozprocess.ProcessHandler([prog, "-unittest"],
cwd=os.getcwd(), cwd=os.getcwd(),
env=env) env=env)
@ -43,17 +42,14 @@ class GTests(object):
outputTimeout=GTests.TEST_PROC_NO_OUTPUT_TIMEOUT) outputTimeout=GTests.TEST_PROC_NO_OUTPUT_TIMEOUT)
proc.wait() proc.wait()
if proc.timedOut: if proc.timedOut:
log.testFail("%s | timed out after %d seconds", log.testFail("gtest | timed out after %d seconds", GTests.TEST_PROC_TIMEOUT)
basename, GTests.TEST_PROC_TIMEOUT)
return False return False
if mozcrash.check_for_crashes(os.getcwd(), symbols_path, if mozcrash.check_for_crashes(os.getcwd(), symbols_path, test_name="gtest"):
test_name=basename): # mozcrash will output the log failure line for us.
log.testFail("%s | test crashed", basename)
return False return False
result = proc.proc.returncode == 0 result = proc.proc.returncode == 0
if not result: if not result:
log.testFail("%s | test failed with return code %d", log.testFail("gtest | test failed with return code %d", proc.proc.returncode)
basename, proc.proc.returncode)
return result return result
def build_core_environment(self, env = {}): def build_core_environment(self, env = {}):