Bug 799291 - Part 3: Move mozbuild.testing into testing/; r=jhammel
--- a/layout/tools/reftest/mach_commands.py
+++ b/layout/tools/reftest/mach_commands.py
@@ -2,30 +2,31 @@
# 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
+
+from moztesting.util import parse_test_path
from mach.base import (
CommandArgument,
CommandProvider,
Command,
)
generic_help = 'Test to run. Can be specified as a single file, a ' +\
'directory, or omitted. If omitted, the entire test suite is executed.'
-class ReftestRunner(TestRunner):
+class ReftestRunner(MozbuildObject):
"""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."""
@@ -33,17 +34,17 @@ class ReftestRunner(TestRunner):
'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)
+ parsed = parse_test_path(test_file, self.topsrcdir)
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')
--- a/mach
+++ b/mach
@@ -23,16 +23,17 @@ SEARCH_PATHS = [
'python/mozbuild',
'build',
'build/pymake',
'python/blessings',
'python/psutil',
'python/which',
'other-licenses/ply',
'xpcom/idl-parser',
+ 'testing',
'testing/xpcshell',
'testing/mozbase/mozprocess',
'testing/mozbase/mozinfo',
]
# Individual files providing mach commands.
MACH_MODULES = [
'layout/tools/reftest/mach_commands.py',
--- a/testing/mochitest/mach_commands.py
+++ b/testing/mochitest/mach_commands.py
@@ -2,30 +2,31 @@
# 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
+
+from moztesting.util import parse_test_path
from mach.base import (
CommandArgument,
CommandProvider,
Command,
)
generic_help = 'Test to run. Can be specified as a single file, a ' +\
'directory, or omitted. If omitted, the entire test suite is executed.'
-class MochitestRunner(TestRunner):
+class MochitestRunner(MozbuildObject):
"""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.
@@ -66,17 +67,17 @@ class MochitestRunner(TestRunner):
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']
+ path = parse_test_path(test_file, self.topsrcdir)['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)
rename from python/mozbuild/mozbuild/testing/test.py
rename to testing/moztesting/util.py
--- a/python/mozbuild/mozbuild/testing/test.py
+++ b/testing/moztesting/util.py
@@ -1,33 +1,29 @@
# 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)
+def parse_test_path(test_path, topsrcdir):
+ """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
- if is_dir and not test_path.endswith(os.path.sep):
- test_path += os.path.sep
+ normalized = test_path
- normalized = test_path
+ if test_path.startswith(topsrcdir):
+ normalized = test_path[len(topsrcdir):]
- if test_path.startswith(self.topsrcdir):
- normalized = test_path[len(self.topsrcdir):]
+ return {
+ 'normalized': normalized,
+ 'is_dir': is_dir,
+ }
- return {
- 'normalized': normalized,
- 'is_dir': is_dir,
- }