зеркало из https://github.com/mozilla/gecko-dev.git
Bug 780698 - Part c: Support mochitest-a11y, reftest, crashtest in mach; r=gps
This commit is contained in:
Родитель
962ca363fa
Коммит
388bca7c1d
|
@ -27,6 +27,12 @@ class Testing(MozbuildObject, ArgumentProvider):
|
|||
mochitest = self._spawn(MochitestRunner)
|
||||
mochitest.run_mochitest_test(test_file, flavor)
|
||||
|
||||
def run_reftest(self, test_file, flavor):
|
||||
from mozbuild.testing.reftest import ReftestRunner
|
||||
|
||||
reftest = self._spawn(ReftestRunner)
|
||||
reftest.run_reftest_test(test_file, flavor)
|
||||
|
||||
def run_xpcshell_test(self, **params):
|
||||
from mozbuild.testing.xpcshell import XPCShellRunner
|
||||
|
||||
|
@ -46,6 +52,7 @@ class Testing(MozbuildObject, ArgumentProvider):
|
|||
|
||||
group.set_defaults(cls=Testing, method='run_suite', suite='all')
|
||||
|
||||
# Mochitest-style
|
||||
mochitest_plain = parser.add_parser('mochitest-plain',
|
||||
help='Run a plain mochitest.')
|
||||
mochitest_plain.add_argument('test_file', default=None, nargs='?',
|
||||
|
@ -67,6 +74,29 @@ class Testing(MozbuildObject, ArgumentProvider):
|
|||
mochitest_browser.set_defaults(cls=Testing, method='run_mochitest',
|
||||
flavor='browser')
|
||||
|
||||
mochitest_a11y = parser.add_parser('mochitest-a11y',
|
||||
help='Run an a11y mochitest.')
|
||||
mochitest_a11y.add_argument('test_file', default=None, nargs='?',
|
||||
metavar='TEST', help=generic_help)
|
||||
mochitest_a11y.set_defaults(cls=Testing, method='run_mochitest',
|
||||
flavor='a11y')
|
||||
|
||||
# Reftest-style
|
||||
reftest = parser.add_parser('reftest',
|
||||
help='Run a reftest.')
|
||||
reftest.add_argument('test_file', default=None, nargs='?',
|
||||
metavar='TEST', help=generic_help)
|
||||
reftest.set_defaults(cls=Testing, method='run_reftest',
|
||||
flavor='reftest')
|
||||
|
||||
crashtest = parser.add_parser('crashtest',
|
||||
help='Run a crashtest.')
|
||||
crashtest.add_argument('test_file', default=None, nargs='?',
|
||||
metavar='TEST', help=generic_help)
|
||||
crashtest.set_defaults(cls=Testing, method='run_reftest',
|
||||
flavor='crashtest')
|
||||
|
||||
# XPCShell-style
|
||||
xpcshell = parser.add_parser('xpcshell-test',
|
||||
help="Run an individual xpcshell test.")
|
||||
|
||||
|
|
|
@ -4,12 +4,10 @@
|
|||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from mozbuild.base import MozbuildObject
|
||||
from mozbuild.testing.test import TestRunner
|
||||
|
||||
|
||||
class MochitestRunner(MozbuildObject):
|
||||
class MochitestRunner(TestRunner):
|
||||
"""Easily run mochitests.
|
||||
|
||||
This currently contains just the basics for running mochitests. We may want
|
||||
|
@ -54,6 +52,8 @@ class MochitestRunner(MozbuildObject):
|
|||
target = 'mochitest-chrome'
|
||||
elif suite == 'browser':
|
||||
target = 'mochitest-browser-chrome'
|
||||
elif suite == 'a11y':
|
||||
target = 'mochitest-a11y'
|
||||
else:
|
||||
raise Exception('None or unrecognized mochitest suite type.')
|
||||
|
||||
|
@ -66,19 +66,3 @@ class MochitestRunner(MozbuildObject):
|
|||
env = {}
|
||||
|
||||
self._run_make(directory='.', target=target, append_env=env)
|
||||
|
||||
def _parse_test_path(self, test_path):
|
||||
is_dir = os.path.isdir(test_path)
|
||||
|
||||
if is_dir and not test_path.endswith(os.path.sep):
|
||||
test_path += os.path.sep
|
||||
|
||||
normalized = test_path
|
||||
|
||||
if test_path.startswith(self.topsrcdir):
|
||||
normalized = test_path[len(self.topsrcdir):]
|
||||
|
||||
return {
|
||||
'normalized': normalized,
|
||||
'is_dir': is_dir,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from mozbuild.testing.test import TestRunner
|
||||
|
||||
|
||||
class ReftestRunner(TestRunner):
|
||||
"""Easily run reftests.
|
||||
|
||||
This currently contains just the basics for running reftests. We may want
|
||||
to hook up result parsing, etc.
|
||||
"""
|
||||
|
||||
def _manifest_file(self, suite):
|
||||
"""Returns the manifest file used for a given test suite."""
|
||||
files = {
|
||||
'reftest': 'reftest.list',
|
||||
'crashtest': 'crashtests.list'
|
||||
}
|
||||
assert suite in files
|
||||
return files[suite]
|
||||
|
||||
def _find_manifest(self, suite, test_file):
|
||||
assert test_file
|
||||
parsed = self._parse_test_path(test_file)
|
||||
if parsed['is_dir']:
|
||||
return os.path.join(parsed['normalized'], self._manifest_file(suite))
|
||||
|
||||
if parsed['normalized'].endswith('.list'):
|
||||
return parsed['normalized']
|
||||
|
||||
raise Exception('Running a single test is not currently supported')
|
||||
|
||||
def run_reftest_test(self, test_file=None, suite=None):
|
||||
"""Runs a reftest.
|
||||
|
||||
test_file is a path to a test file. It can be a relative path from the
|
||||
top source directory, an absolute filename, or a directory containing
|
||||
test files.
|
||||
|
||||
suite is the type of reftest to run. It can be one of ('reftest',
|
||||
'crashtest').
|
||||
"""
|
||||
|
||||
if suite not in ('reftest', 'crashtest'):
|
||||
raise Exception('None or unrecognized reftest suite type.')
|
||||
|
||||
if test_file:
|
||||
path = self._find_manifest(suite, test_file)
|
||||
if not os.path.exists(path):
|
||||
raise Exception('No manifest file was found at %s.' % path)
|
||||
env = {'TEST_PATH': path}
|
||||
else:
|
||||
env = {}
|
||||
|
||||
# TODO hook up harness via native Python
|
||||
self._run_make(directory='.', target=suite, append_env=env)
|
|
@ -0,0 +1,33 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import os
|
||||
|
||||
from mozbuild.base import MozbuildObject
|
||||
|
||||
|
||||
class TestRunner(MozbuildObject):
|
||||
"""Base class to share code for parsing test paths."""
|
||||
|
||||
def _parse_test_path(self, test_path):
|
||||
"""Returns a dict containing:
|
||||
* 'normalized': the normalized path, relative to the topsrcdir
|
||||
* 'isdir': whether the path points to a directory
|
||||
"""
|
||||
is_dir = os.path.isdir(test_path)
|
||||
|
||||
if is_dir and not test_path.endswith(os.path.sep):
|
||||
test_path += os.path.sep
|
||||
|
||||
normalized = test_path
|
||||
|
||||
if test_path.startswith(self.topsrcdir):
|
||||
normalized = test_path[len(self.topsrcdir):]
|
||||
|
||||
return {
|
||||
'normalized': normalized,
|
||||
'is_dir': is_dir,
|
||||
}
|
Загрузка…
Ссылка в новой задаче