Bug 1087567 - Add proper manifest for cppunit tests; r=ted

This commit is contained in:
Dan Minor
2014-10-28 09:38:21 -04:00
parent 5a7eeff70c
commit 460fdebe82
7 changed files with 158 additions and 56 deletions

View File

@@ -7,6 +7,7 @@
from __future__ import with_statement
import sys, os, tempfile, shutil
from optparse import OptionParser
import manifestparser
import mozprocess
import mozinfo
import mozcrash
@@ -174,29 +175,30 @@ class CPPUnittestOptions(OptionParser):
default = None,
help = "absolute path to a manifest file")
def extract_unittests_from_args(args, manifest_file):
def extract_unittests_from_args(args, environ):
"""Extract unittests from args, expanding directories as needed"""
progs = []
# Known files commonly packaged with the cppunittests that are not tests
skipped_progs = set(['.mkdir.done', 'remotecppunittests.py', 'runcppunittests.py', 'runcppunittests.pyc'])
if manifest_file:
skipped_progs.add(os.path.basename(manifest_file))
with open(manifest_file) as f:
for line in f:
# strip out comment, if any
prog = line.split('#')[0]
if prog:
skipped_progs.add(prog.strip())
mp = manifestparser.TestManifest(strict=True)
tests = []
for p in args:
if os.path.isdir(p):
progs.extend([os.path.abspath(os.path.join(p, x)) for x in os.listdir(p) if not x in skipped_progs])
elif p not in skipped_progs:
progs.append(os.path.abspath(p))
try:
mp.read(os.path.join(p, 'cppunittest.ini'))
except IOError:
tests.extend([os.path.abspath(os.path.join(p, x)) for x in os.listdir(p)])
else:
tests.append(os.path.abspath(p))
return progs
# we skip the existence check here because not all tests are built
# for all platforms (and it will fail on Windows anyway)
if mozinfo.isWin:
tests.extend([test['path'] + '.exe' for test in mp.active_tests(exists=False, disabled=False, **environ)])
else:
tests.extend([test['path'] for test in mp.active_tests(exists=False, disabled=False, **environ)])
# skip non-existing tests
tests = [test for test in tests if os.path.isfile(test)]
return tests
def main():
parser = CPPUnittestOptions()
@@ -213,7 +215,7 @@ def main():
options,
{"tbpl": sys.stdout})
progs = extract_unittests_from_args(args, options.manifest_file)
progs = extract_unittests_from_args(args, mozinfo.info)
options.xre_path = os.path.abspath(options.xre_path)
if mozinfo.isMac:
options.xre_path = os.path.join(os.path.dirname(options.xre_path), 'Resources')