Bug 1171299 - Support mozinfo.json in cppunit tests. r=dminor, a=test-only
--- a/testing/remotecppunittests.py
+++ b/testing/remotecppunittests.py
@@ -6,16 +6,17 @@
import os, sys
import subprocess
import tempfile
from zipfile import ZipFile
import runcppunittests as cppunittests
import mozcrash
import mozfile
+import mozinfo
import StringIO
import posixpath
from mozdevice import devicemanager, devicemanagerADB, devicemanagerSUT
from mozlog import structured
try:
from mozbuild.base import MozbuildObject
build_obj = MozbuildObject.from_environment()
@@ -249,21 +250,18 @@ def main():
sys.exit(1)
log = structured.commandline.setup_logging("remotecppunittests",
options,
{"tbpl": sys.stdout})
options.xre_path = os.path.abspath(options.xre_path)
- if options.with_b2g_emulator:
- environ = {'os': 'b2g'}
- else:
- environ = {'os': 'android'}
- progs = cppunittests.extract_unittests_from_args(args, environ)
+ cppunittests.update_mozinfo()
+ progs = cppunittests.extract_unittests_from_args(args, mozinfo.info)
tester = RemoteCPPUnitTests(dm, options, progs)
try:
result = tester.run_tests(progs, options.xre_path, options.symbols_path)
except Exception, e:
log.error(str(e))
result = False
if options.with_b2g_emulator:
runner.cleanup()
--- a/testing/runcppunittests.py
+++ b/testing/runcppunittests.py
@@ -11,16 +11,18 @@ import manifestparser
import mozprocess
import mozinfo
import mozcrash
import mozfile
from contextlib import contextmanager
from mozlog import structured
from subprocess import PIPE
+SCRIPT_DIR = os.path.abspath(os.path.realpath(os.path.dirname(__file__)))
+
class CPPUnitTests(object):
# Time (seconds) to wait for test process to complete
TEST_PROC_TIMEOUT = 900
# 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, interactive=False):
"""
@@ -195,31 +197,43 @@ def extract_unittests_from_args(args, en
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 update_mozinfo():
+ """walk up directories to find mozinfo.json update the info"""
+ path = SCRIPT_DIR
+ dirs = set()
+ while path != os.path.expanduser('~'):
+ if path in dirs:
+ break
+ dirs.add(path)
+ path = os.path.split(path)[0]
+ mozinfo.find_and_update_from_json(*dirs)
+
def main():
parser = CPPUnittestOptions()
structured.commandline.add_logging_group(parser)
options, args = parser.parse_args()
if not args:
print >>sys.stderr, """Usage: %s <test binary> [<test binary>...]""" % sys.argv[0]
sys.exit(1)
if not options.xre_path:
print >>sys.stderr, """Error: --xre-path is required"""
sys.exit(1)
log = structured.commandline.setup_logging("cppunittests",
options,
{"tbpl": sys.stdout})
+ update_mozinfo()
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')
tester = CPPUnitTests()
try:
result = tester.run_tests(progs, options.xre_path, options.symbols_path)
--- a/testing/testsuite-targets.mk
+++ b/testing/testsuite-targets.mk
@@ -512,16 +512,17 @@ stage-cppunittests: make-stage-dir
ifdef STRIP_CPP_TESTS
$(foreach bin,$(CPP_UNIT_TEST_BINS),$(OBJCOPY) $(or $(STRIP_FLAGS),--strip-unneeded) $(bin) $(bin:$(DIST)/%=$(PKG_STAGE)/%);)
else
cp -RL $(DIST)/cppunittests $(PKG_STAGE)
endif
cp $(topsrcdir)/testing/runcppunittests.py $(PKG_STAGE)/cppunittests
cp $(topsrcdir)/testing/remotecppunittests.py $(PKG_STAGE)/cppunittests
cp $(topsrcdir)/testing/cppunittest.ini $(PKG_STAGE)/cppunittests
+ cp $(DEPTH)/mozinfo.json $(PKG_STAGE)/cppunittests
ifeq ($(MOZ_DISABLE_STARTUPCACHE),)
cp $(topsrcdir)/startupcache/test/TestStartupCacheTelemetry.js $(PKG_STAGE)/cppunittests
cp $(topsrcdir)/startupcache/test/TestStartupCacheTelemetry.manifest $(PKG_STAGE)/cppunittests
endif
ifdef STRIP_CPP_TESTS
$(OBJCOPY) $(or $(STRIP_FLAGS),--strip-unneeded) $(DIST)/bin/jsapi-tests$(BIN_SUFFIX) $(PKG_STAGE)/cppunittests/jsapi-tests$(BIN_SUFFIX)
else
cp -RL $(DIST)/bin/jsapi-tests$(BIN_SUFFIX) $(PKG_STAGE)/cppunittests