Skip to content

Commit

Permalink
Bug 1317970 - Use manifestparser manifests for python unit tests, r=c…
Browse files Browse the repository at this point in the history
…hmanchester

This deprecates PYTHON_UNIT_TESTS and replaces it with PYTHON_UNITTEST_MANIFESTS.
In the build system, this means python unittests will be treated the same as all
other test suites that use manifestparser. New manifests called 'python.ini' have
been created for all test directories containing python unittests.

MozReview-Commit-ID: IBHG7Thif2D
  • Loading branch information
ahal committed Nov 16, 2016
1 parent fbfb50f commit 215be8e
Show file tree
Hide file tree
Showing 35 changed files with 133 additions and 284 deletions.
1 change: 1 addition & 0 deletions build/compare-mozconfig/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[compare-mozconfigs-wrapper.py]
4 changes: 2 additions & 2 deletions build/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ for var in ('MOZ_CRASHREPORTER', 'MOZ_PROFILE_MIGRATOR',
DEFINES[var] = True

if CONFIG['MOZ_BUILD_APP'] == 'browser':
PYTHON_UNIT_TESTS += [
'compare-mozconfig/compare-mozconfigs-wrapper.py',
PYTHON_UNITTEST_MANIFESTS += [
'compare-mozconfig/python.ini',
]

if CONFIG['ENABLE_TESTS'] or CONFIG['MOZ_DMD']:
Expand Down
8 changes: 2 additions & 6 deletions config/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,8 @@ if CONFIG['HOST_OS_ARCH'] != 'WINNT':
if CONFIG['MOZ_SYSTEM_ICU']:
DEFINES['MOZ_SYSTEM_ICU'] = True

PYTHON_UNIT_TESTS += [
'tests/test_mozbuild_reading.py',
'tests/unit-expandlibs.py',
'tests/unit-mozunit.py',
'tests/unit-nsinstall.py',
'tests/unit-printprereleasesuffix.py',
PYTHON_UNITTEST_MANIFESTS += [
'tests/python.ini',
]

if CONFIG['GNU_CC'] and CONFIG['MOZ_OPTIMIZE']:
Expand Down
5 changes: 5 additions & 0 deletions config/tests/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[test_mozbuild_reading.py]
[unit-expandlibs.py]
[unit-mozunit.py]
[unit-nsinstall.py]
[unit-printprereleasesuffix.py]
4 changes: 2 additions & 2 deletions dom/bindings/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ if CONFIG['MOZ_BUILD_APP'] in ['browser', 'mobile/android', 'xulrunner']:
DEFINES['HAVE_SIDEBAR'] = True


PYTHON_UNIT_TESTS += [
'mozwebidlcodegen/test/test_mozwebidlcodegen.py',
PYTHON_UNITTEST_MANIFESTS += [
'mozwebidlcodegen/test/python.ini',
]

if CONFIG['GNU_CXX']:
Expand Down
1 change: 1 addition & 0 deletions dom/bindings/mozwebidlcodegen/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[test_mozwebidlcodegen.py]
2 changes: 1 addition & 1 deletion mozglue/linker/tests/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ USE_LIBS += [
OS_LIBS += CONFIG['MOZ_ZLIB_LIBS']
DISABLE_STL_WRAPPING = True

PYTHON_UNIT_TESTS += ['run_test_zip.py']
PYTHON_UNITTEST_MANIFESTS += ['python.ini']

if CONFIG['GNU_CXX']:
CXXFLAGS += ['-Wno-error=shadow']
1 change: 1 addition & 0 deletions mozglue/linker/tests/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[run_test_zip.py]
6 changes: 6 additions & 0 deletions python/mach/mach/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[test_conditions.py]
[test_config.py]
[test_dispatcher.py]
[test_entry_point.py]
[test_error_output.py]
[test_logger.py]
6 changes: 3 additions & 3 deletions python/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def python(self, args):
@CommandArgument('tests', nargs='*',
metavar='TEST',
help=('Tests to run. Each test can be a single file or a directory. '
'Default test resolution relies on PYTHON_UNIT_TESTS.'))
'Default test resolution relies on PYTHON_UNITTEST_MANIFESTS.'))
def python_test(self,
tests=[],
test_objects=None,
Expand Down Expand Up @@ -118,13 +118,13 @@ def find_tests_by_path():
test_objects = resolver.resolve_tests(paths=tests,
flavor='python')
else:
# Otherwise just run everything in PYTHON_UNIT_TESTS
# Otherwise just run everything in PYTHON_UNITTEST_MANIFESTS
test_objects = resolver.resolve_tests(flavor='python')

if not test_objects:
message = 'TEST-UNEXPECTED-FAIL | No tests collected'
if not path_only:
message += ' (Not in PYTHON_UNIT_TESTS? Try --path-only?)'
message += ' (Not in PYTHON_UNITTEST_MANIFESTS? Try --path-only?)'
self.log(logging.WARN, 'python-test', {}, message)
return 1

Expand Down
71 changes: 6 additions & 65 deletions python/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,69 +20,10 @@ SPHINX_PYTHON_PACKAGE_DIRS += [

SPHINX_TREES['mach'] = 'mach/docs'

PYTHON_UNIT_TESTS += [
'mach/mach/test/test_conditions.py',
'mach/mach/test/test_config.py',
'mach/mach/test/test_dispatcher.py',
'mach/mach/test/test_entry_point.py',
'mach/mach/test/test_error_output.py',
'mach/mach/test/test_logger.py',
'mozbuild/dumbmake/test/test_dumbmake.py',
'mozbuild/mozbuild/test/action/test_buildlist.py',
'mozbuild/mozbuild/test/action/test_generate_browsersearch.py',
'mozbuild/mozbuild/test/action/test_package_fennec_apk.py',
'mozbuild/mozbuild/test/backend/test_android_eclipse.py',
'mozbuild/mozbuild/test/backend/test_build.py',
'mozbuild/mozbuild/test/backend/test_configenvironment.py',
'mozbuild/mozbuild/test/backend/test_recursivemake.py',
'mozbuild/mozbuild/test/backend/test_visualstudio.py',
'mozbuild/mozbuild/test/compilation/test_warnings.py',
'mozbuild/mozbuild/test/configure/lint.py',
'mozbuild/mozbuild/test/configure/test_checks_configure.py',
'mozbuild/mozbuild/test/configure/test_compile_checks.py',
'mozbuild/mozbuild/test/configure/test_configure.py',
'mozbuild/mozbuild/test/configure/test_lint.py',
'mozbuild/mozbuild/test/configure/test_moz_configure.py',
'mozbuild/mozbuild/test/configure/test_options.py',
'mozbuild/mozbuild/test/configure/test_toolchain_configure.py',
'mozbuild/mozbuild/test/configure/test_toolchain_helpers.py',
'mozbuild/mozbuild/test/configure/test_toolkit_moz_configure.py',
'mozbuild/mozbuild/test/configure/test_util.py',
'mozbuild/mozbuild/test/controller/test_ccachestats.py',
'mozbuild/mozbuild/test/controller/test_clobber.py',
'mozbuild/mozbuild/test/frontend/test_context.py',
'mozbuild/mozbuild/test/frontend/test_emitter.py',
'mozbuild/mozbuild/test/frontend/test_namespaces.py',
'mozbuild/mozbuild/test/frontend/test_reader.py',
'mozbuild/mozbuild/test/frontend/test_sandbox.py',
'mozbuild/mozbuild/test/test_base.py',
'mozbuild/mozbuild/test/test_containers.py',
'mozbuild/mozbuild/test/test_dotproperties.py',
'mozbuild/mozbuild/test/test_expression.py',
'mozbuild/mozbuild/test/test_jarmaker.py',
'mozbuild/mozbuild/test/test_line_endings.py',
'mozbuild/mozbuild/test/test_makeutil.py',
'mozbuild/mozbuild/test/test_mozconfig.py',
'mozbuild/mozbuild/test/test_mozinfo.py',
'mozbuild/mozbuild/test/test_preprocessor.py',
'mozbuild/mozbuild/test/test_pythonutil.py',
'mozbuild/mozbuild/test/test_testing.py',
'mozbuild/mozbuild/test/test_util.py',
'mozbuild/mozpack/test/test_chrome_flags.py',
'mozbuild/mozpack/test/test_chrome_manifest.py',
'mozbuild/mozpack/test/test_copier.py',
'mozbuild/mozpack/test/test_errors.py',
'mozbuild/mozpack/test/test_files.py',
'mozbuild/mozpack/test/test_manifests.py',
'mozbuild/mozpack/test/test_mozjar.py',
'mozbuild/mozpack/test/test_packager.py',
'mozbuild/mozpack/test/test_packager_formats.py',
'mozbuild/mozpack/test/test_packager_l10n.py',
'mozbuild/mozpack/test/test_packager_unpack.py',
'mozbuild/mozpack/test/test_path.py',
'mozbuild/mozpack/test/test_unify.py',
'mozlint/test/test_formatters.py',
'mozlint/test/test_parser.py',
'mozlint/test/test_roller.py',
'mozlint/test/test_types.py',
PYTHON_UNITTEST_MANIFESTS += [
'mach/mach/test/python.ini',
'mozbuild/dumbmake/test/python.ini',
'mozbuild/mozbuild/test/python.ini',
'mozbuild/mozpack/test/python.ini',
'mozlint/test/python.ini',
]
1 change: 1 addition & 0 deletions python/mozbuild/dumbmake/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[test_dumbmake.py]
1 change: 0 additions & 1 deletion python/mozbuild/mozbuild/backend/recursivemake.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
b'PARALLEL_DIRS',
b'PREF_JS_EXPORTS',
b'PROGRAM',
b'PYTHON_UNIT_TESTS',
b'RESOURCE_FILES',
b'SDK_HEADERS',
b'SDK_LIBRARY',
Expand Down
9 changes: 5 additions & 4 deletions python/mozbuild/mozbuild/frontend/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -1154,10 +1154,6 @@ def aggregate(files):
Implies FORCE_SHARED_LIB.
"""),

'PYTHON_UNIT_TESTS': (StrictOrderingOnAppendList, list,
"""A list of python unit tests.
"""),

'HOST_LIBRARY_NAME': (unicode, unicode,
"""Name of target library generated when cross compiling.
"""),
Expand Down Expand Up @@ -1575,6 +1571,11 @@ def aggregate(files):
"""List of manifest files defining xpcshell tests.
"""),

'PYTHON_UNITTEST_MANIFESTS': (ManifestparserManifestList, list,
"""List of manifest files defining python unit tests.
"""),


# The following variables are used to control the target of installed files.
'XPI_NAME': (unicode, unicode,
"""The name of an extension XPI to generate.
Expand Down
36 changes: 0 additions & 36 deletions python/mozbuild/mozbuild/frontend/emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,6 @@ def emit_from_context(self, context):
'ANDROID_GENERATED_RESFILES',
'DISABLE_STL_WRAPPING',
'EXTRA_DSO_LDOPTS',
'PYTHON_UNIT_TESTS',
'RCFILE',
'RESFILE',
'RCINCLUDE',
Expand Down Expand Up @@ -1260,11 +1259,6 @@ def _process_test_manifests(self, context):
for obj in self._process_web_platform_tests_manifest(context, path, manifest):
yield obj

python_tests = context.get('PYTHON_UNIT_TESTS')
if python_tests:
for obj in self._process_python_tests(context, python_tests):
yield obj

def _process_test_manifest(self, context, info, manifest_path, mpmanifest):
flavor, install_root, install_subdir, package_tests = info

Expand Down Expand Up @@ -1430,36 +1424,6 @@ def _process_web_platform_tests_manifest(self, context, paths, manifest):

yield obj

def _process_python_tests(self, context, python_tests):
manifest_full_path = context.main_path
manifest_reldir = mozpath.dirname(mozpath.relpath(manifest_full_path,
context.config.topsrcdir))

obj = TestManifest(context, manifest_full_path,
mozpath.basename(manifest_full_path),
flavor='python', install_prefix='python/',
relpath=mozpath.join(manifest_reldir,
mozpath.basename(manifest_full_path)))

for test in python_tests:
test = mozpath.normpath(mozpath.join(context.srcdir, test))
if not os.path.isfile(test):
raise SandboxValidationError('Path specified in '
'PYTHON_UNIT_TESTS does not exist: %s' % test,
context)
obj.tests.append({
'path': test,
'here': mozpath.dirname(test),
'manifest': manifest_full_path,
'name': mozpath.basename(test),
'head': '',
'tail': '',
'support-files': '',
'subsuite': '',
})

yield obj

def _process_jar_manifests(self, context):
jar_manifests = context.get('JAR_MANIFESTS', [])
if len(jar_manifests) > 1:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ MOCHITEST_CHROME_MANIFESTS += ['chrome.ini']
XPCSHELL_TESTS_MANIFESTS += ['xpcshell.ini']
REFTEST_MANIFESTS += ['reftest.list']
CRASHTEST_MANIFESTS += ['crashtest.list']
PYTHON_UNIT_TESTS += ['test_foo.py']
PYTHON_UNITTEST_MANIFESTS += ['python.ini']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[test_foo.py]

This file was deleted.

13 changes: 4 additions & 9 deletions python/mozbuild/mozbuild/test/frontend/test_emitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -540,13 +540,6 @@ def test_test_manifest_includes(self):
for t in obj.tests:
self.assertTrue(t['manifest'].endswith(expected_manifests[t['name']]))

def test_python_unit_test_missing(self):
"""Missing files in PYTHON_UNIT_TESTS should raise."""
reader = self.reader('test-python-unit-test-missing')
with self.assertRaisesRegexp(SandboxValidationError,
'Path specified in PYTHON_UNIT_TESTS does not exist:'):
self.read_topsrcdir(reader)

def test_test_manifest_keys_extracted(self):
"""Ensure all metadata from test manifests is extracted."""
reader = self.reader('test-manifest-keys-extracted')
Expand Down Expand Up @@ -619,9 +612,11 @@ def test_test_manifest_keys_extracted(self):
'flavor': 'crashtest',
'installs': {},
},
'moz.build': {
'python.ini': {
'flavor': 'python',
'installs': {},
'installs': {
'python.ini': False,
},
}
}

Expand Down
40 changes: 40 additions & 0 deletions python/mozbuild/mozbuild/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[action/test_buildlist.py]
[action/test_generate_browsersearch.py]
[action/test_package_fennec_apk.py]
[backend/test_android_eclipse.py]
[backend/test_build.py]
[backend/test_configenvironment.py]
[backend/test_recursivemake.py]
[backend/test_visualstudio.py]
[compilation/test_warnings.py]
[configure/lint.py]
[configure/test_checks_configure.py]
[configure/test_compile_checks.py]
[configure/test_configure.py]
[configure/test_lint.py]
[configure/test_moz_configure.py]
[configure/test_options.py]
[configure/test_toolchain_configure.py]
[configure/test_toolchain_helpers.py]
[configure/test_toolkit_moz_configure.py]
[configure/test_util.py]
[controller/test_ccachestats.py]
[controller/test_clobber.py]
[frontend/test_context.py]
[frontend/test_emitter.py]
[frontend/test_namespaces.py]
[frontend/test_reader.py]
[frontend/test_sandbox.py]
[test_base.py]
[test_containers.py]
[test_dotproperties.py]
[test_expression.py]
[test_jarmaker.py]
[test_line_endings.py]
[test_makeutil.py]
[test_mozconfig.py]
[test_mozinfo.py]
[test_preprocessor.py]
[test_pythonutil.py]
[test_testing.py]
[test_util.py]
4 changes: 2 additions & 2 deletions python/mozbuild/mozbuild/testing.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ def resolve_tests(self, cwd=None, **kwargs):
FIREFOX_UI_FUNCTIONAL=('firefox-ui-functional', 'firefox-ui', '.', False),
FIREFOX_UI_UPDATE=('firefox-ui-update', 'firefox-ui', '.', False),
PUPPETEER_FIREFOX=('firefox-ui-functional', 'firefox-ui', '.', False),
PYTHON_UNITTEST=('python', 'python', '.', False),

# marionette tests are run from the srcdir
# TODO(ato): make packaging work as for other test suites
Expand All @@ -311,8 +312,7 @@ def resolve_tests(self, cwd=None, **kwargs):
def all_test_flavors():
return ([v[0] for v in TEST_MANIFESTS.values()] +
list(REFTEST_FLAVORS) +
list(WEB_PLATFORM_TESTS_FLAVORS) +
['python'])
list(WEB_PLATFORM_TESTS_FLAVORS))

class TestInstallInfo(object):
def __init__(self):
Expand Down
13 changes: 13 additions & 0 deletions python/mozbuild/mozpack/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[test_chrome_flags.py]
[test_chrome_manifest.py]
[test_copier.py]
[test_errors.py]
[test_files.py]
[test_manifests.py]
[test_mozjar.py]
[test_packager.py]
[test_packager_formats.py]
[test_packager_l10n.py]
[test_packager_unpack.py]
[test_path.py]
[test_unify.py]
4 changes: 4 additions & 0 deletions python/mozlint/test/python.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[test_formatters.py]
[test_parser.py]
[test_roller.py]
[test_types.py]
6 changes: 2 additions & 4 deletions testing/mozbase/docs/manifestparser.rst
Original file line number Diff line number Diff line change
Expand Up @@ -455,12 +455,10 @@ To update from a directory of tests in `~/mozmill/src/mozmill-tests/firefox/` ru
Tests
`````

manifestparser includes a suite of tests:

https://github.com/mozilla/mozbase/tree/master/manifestparsery/tests
manifestparser includes a suite of tests.

`test_manifest.txt` is a doctest that may be helpful in figuring out
how to use the API. Tests are run via `python test.py`.
how to use the API. Tests are run via `mach python-test testing/mozbase/manifestparser`.

Bugs
````
Expand Down
Loading

0 comments on commit 215be8e

Please sign in to comment.