Bug 1301431 - Stop using imp to import reftest module on Android, r=gbrown

Android reftests still use os.chdir and imp to import reftest files. But there's a
_setup_objdir method (used by b2g) that does a similar thing instead. I decided to
try getting Android to use this as well and it seems to work. This is just a cleanup.

MozReview-Commit-ID: 5HMfm64wmK2

--HG--
extra : rebase_source : b9f52c01e0d1311a0c4511ffbc0a60e7d149ffe8
This commit is contained in:
Andrew Halberstadt 2016-09-13 09:26:04 -04:00
Родитель ac4b6dabc5
Коммит ff33b36e48
1 изменённых файлов: 4 добавлений и 16 удалений

Просмотреть файл

@ -210,13 +210,15 @@ class ReftestRunner(MozbuildObject):
def run_android_test(self, **kwargs):
"""Runs a reftest, in Firefox for Android."""
import runreftest
if kwargs["suite"] not in ('reftest', 'crashtest', 'jstestbrowser'):
raise Exception('None or unrecognized reftest suite type.')
if "ipc" in kwargs.keys():
raise Exception('IPC tests not supported on Android.')
self._setup_objdir(**kwargs)
import remotereftest
default_manifest = {
"reftest": (self.topsrcdir, "layout", "reftests", "reftest.list"),
"crashtest": (self.topsrcdir, "testing", "crashtest", "crashtests.list"),
@ -273,23 +275,9 @@ class ReftestRunner(MozbuildObject):
path = os.path.relpath(path, os.path.join(self.topsrcdir))
kwargs["tests"][i] = os.path.join('tests', path)
# Need to chdir to reftest_dir otherwise imports fail below.
os.chdir(self.reftest_dir)
# The imp module can spew warnings if the modules below have
# already been imported, ignore them.
with warnings.catch_warnings():
warnings.simplefilter('ignore')
import imp
path = os.path.join(self.reftest_dir, 'remotereftest.py')
with open(path, 'r') as fh:
imp.load_module('reftest', fh, path, ('.py', 'r', imp.PY_SOURCE))
import reftest
self.log_manager.enable_unstructured()
try:
rv = reftest.run(**kwargs)
rv = remotereftest.run(**kwargs)
finally:
self.log_manager.disable_unstructured()