author | Ms2ger <ms2ger@gmail.com> |
Tue, 02 Oct 2012 10:24:12 +0200 | |
changeset 108822 | 111089855ef805f814a3eded6ec9961353d16313 |
parent 108821 | 1b36381b4b6bb1122d9deee7c5fd504eadd28508 |
child 108823 | 50fde7a256f154d3bfc47dbb0ca9bd5f8ee95042 |
push id | 23593 |
push user | Ms2ger@gmail.com |
push date | Tue, 02 Oct 2012 08:25:46 +0000 |
treeherder | mozilla-central@e5f2c48f10c2 [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | gps |
bugs | 780698 |
milestone | 18.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/python/mach/mach/testing.py +++ b/python/mach/mach/testing.py @@ -22,16 +22,22 @@ class Testing(MozbuildObject, ArgumentPr s.run_suite(suite) def run_mochitest(self, test_file, flavor): from mozbuild.testing.mochitest import MochitestRunner 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 xpcshell = self._spawn(XPCShellRunner) xpcshell.run_test(**params) @staticmethod def populate_argparse(parser): @@ -41,16 +47,17 @@ class Testing(MozbuildObject, ArgumentPr suites = set(['xpcshell', 'mochitest-plain', 'mochitest-chrome', 'mochitest-browser', 'all']) group.add_argument('suite', default='all', choices=suites, nargs='?', help="Test suite to run.") 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='?', metavar='TEST', help=generic_help) mochitest_plain.set_defaults(cls=Testing, method='run_mochitest', flavor='plain') mochitest_chrome = parser.add_parser('mochitest-chrome', @@ -62,16 +69,39 @@ class Testing(MozbuildObject, ArgumentPr mochitest_browser = parser.add_parser('mochitest-browser', help='Run a mochitest with browser chrome.') mochitest_browser.add_argument('test_file', default=None, nargs='?', metavar='TEST', help=generic_help) 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.") xpcshell.add_argument('test_file', default='all', nargs='?', metavar='TEST', help=generic_help) xpcshell.add_argument('--debug', '-d', action='store_true', help='Run test in debugger.')
--- a/python/mozbuild/mozbuild/testing/mochitest.py +++ b/python/mozbuild/mozbuild/testing/mochitest.py @@ -1,20 +1,18 @@ # 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 +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 to hook up result parsing, etc. """ def run_plain_suite(self): """Runs all plain mochitests.""" # TODO hook up Python harness runner. @@ -49,36 +47,22 @@ class MochitestRunner(MozbuildObject): # TODO hook up harness via native Python target = None if suite == 'plain': target = 'mochitest-plain' elif suite == 'chrome': 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.') if test_file: path = self._parse_test_path(test_file)['normalized'] if not os.path.exists(path): raise Exception('No manifest file was found at %s.' % path) env = {'TEST_PATH': path} else: 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, - }
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/testing/reftest.py @@ -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)
new file mode 100644 --- /dev/null +++ b/python/mozbuild/mozbuild/testing/test.py @@ -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, + }