зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1242051 - Extract support files processing from the emitter. r=gps
This extracts the logic from the emitter that handles support files in ini manifests to a seperate function in testing.py, so that this logic can be re-used to determine how to install all the files necessary to run a particular test fon the corresponding object in all-tests.json. MozReview-Commit-ID: GSEhEGm09IL
This commit is contained in:
Родитель
328e2a6882
Коммит
fc15bfd0ee
|
@ -83,6 +83,7 @@ from ..testing import (
|
|||
TEST_MANIFESTS,
|
||||
REFTEST_FLAVORS,
|
||||
WEB_PLATFORM_TESTS_FLAVORS,
|
||||
convert_support_files,
|
||||
)
|
||||
|
||||
from .context import (
|
||||
|
@ -1096,63 +1097,23 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
defaults['install-to-subdir'],
|
||||
mozpath.basename(path))
|
||||
|
||||
|
||||
# "head" and "tail" lists.
|
||||
# All manifests support support-files.
|
||||
#
|
||||
# Keep a set of already seen support file patterns, because
|
||||
# repeatedly processing the patterns from the default section
|
||||
# for every test is quite costly (see bug 922517).
|
||||
extras = (('head', set()),
|
||||
('tail', set()),
|
||||
('support-files', set()))
|
||||
('support-files', set()),
|
||||
('generated-files', set()))
|
||||
def process_support_files(test):
|
||||
for thing, seen in extras:
|
||||
value = test.get(thing, '')
|
||||
if value in seen:
|
||||
continue
|
||||
seen.add(value)
|
||||
for pattern in value.split():
|
||||
# We only support globbing on support-files because
|
||||
# the harness doesn't support * for head and tail.
|
||||
if '*' in pattern and thing == 'support-files':
|
||||
obj.pattern_installs.append(
|
||||
(manifest_dir, pattern, out_dir))
|
||||
# "absolute" paths identify files that are to be
|
||||
# placed in the install_root directory (no globs)
|
||||
elif pattern[0] == '/':
|
||||
full = mozpath.normpath(mozpath.join(manifest_dir,
|
||||
mozpath.basename(pattern)))
|
||||
obj.installs[full] = (mozpath.join(install_root,
|
||||
pattern[1:]), False)
|
||||
else:
|
||||
full = mozpath.normpath(mozpath.join(manifest_dir,
|
||||
pattern))
|
||||
patterns, installs, external = convert_support_files(extras, test,
|
||||
install_root,
|
||||
manifest_dir,
|
||||
out_dir)
|
||||
|
||||
dest_path = mozpath.join(out_dir, pattern)
|
||||
|
||||
# If the path resolves to a different directory
|
||||
# tree, we take special behavior depending on the
|
||||
# entry type.
|
||||
if not full.startswith(manifest_dir):
|
||||
# If it's a support file, we install the file
|
||||
# into the current destination directory.
|
||||
# This implementation makes installing things
|
||||
# with custom prefixes impossible. If this is
|
||||
# needed, we can add support for that via a
|
||||
# special syntax later.
|
||||
if thing == 'support-files':
|
||||
dest_path = mozpath.join(out_dir,
|
||||
os.path.basename(pattern))
|
||||
# If it's not a support file, we ignore it.
|
||||
# This preserves old behavior so things like
|
||||
# head files doesn't get installed multiple
|
||||
# times.
|
||||
else:
|
||||
continue
|
||||
|
||||
obj.installs[full] = (mozpath.normpath(dest_path),
|
||||
False)
|
||||
obj.pattern_installs.extend(patterns)
|
||||
for source, dest in installs:
|
||||
obj.installs[source] = (dest, False)
|
||||
obj.external_installs |= external
|
||||
|
||||
for test in filtered:
|
||||
obj.tests.append(test)
|
||||
|
@ -1185,10 +1146,8 @@ class TreeMetadataEmitter(LoggingMixin):
|
|||
del obj.installs[mozpath.join(manifest_dir, f)]
|
||||
except KeyError:
|
||||
raise SandboxValidationError('Error processing test '
|
||||
'manifest %s: entry in generated-files not present '
|
||||
'elsewhere in manifest: %s' % (path, f), context)
|
||||
|
||||
obj.external_installs.add(mozpath.join(out_dir, f))
|
||||
'manifest %s: entry in generated-files not present '
|
||||
'elsewhere in manifest: %s' % (path, f), context)
|
||||
|
||||
yield obj
|
||||
except (AssertionError, Exception):
|
||||
|
|
|
@ -287,6 +287,70 @@ def all_test_flavors():
|
|||
list(WEB_PLATFORM_TESTS_FLAVORS) +
|
||||
['python'])
|
||||
|
||||
def convert_support_files(extras, test, install_root, manifest_dir, out_dir):
|
||||
# Processes a "support-files" entry from a test object and returns
|
||||
# the installs to perform for this test object.
|
||||
#
|
||||
# Arguments:
|
||||
# extras - Tuples used for the basis of memoization (the same support-files
|
||||
# in the same manifest always have the same effect).
|
||||
# test - The test object to process.
|
||||
# install_root - The directory under $objdir/_tests that will contain
|
||||
# the tests for this harness (examples are "testing/mochitest",
|
||||
# "xpcshell").
|
||||
# manifest_dir - Absoulute path to the (srcdir) directory containing the
|
||||
# manifest that included this test
|
||||
# out_dir - The path relative to $objdir/_tests used as the destination for the
|
||||
# test, based on the relative path to the manifest in the srcdir,
|
||||
# the install_root, and 'install-to-subdir', if present in the manifest.
|
||||
pattern_installs, installs, external = [], [], set()
|
||||
for thing, seen in extras:
|
||||
value = test.get(thing, '')
|
||||
# We need to memoize on the basis of both the path and the output
|
||||
# directory for the benefit of tests specifying 'install-to-subdir'.
|
||||
if (value, out_dir) in seen:
|
||||
continue
|
||||
seen.add((value, out_dir))
|
||||
for pattern in value.split():
|
||||
if thing == 'generated-files':
|
||||
external.add(mozpath.join(out_dir, pattern))
|
||||
# We only support globbing on support-files because
|
||||
# the harness doesn't support * for head and tail.
|
||||
elif '*' in pattern and thing == 'support-files':
|
||||
pattern_installs.append((manifest_dir, pattern, out_dir))
|
||||
# "absolute" paths identify files that are to be
|
||||
# placed in the install_root directory (no globs)
|
||||
elif pattern[0] == '/':
|
||||
full = mozpath.normpath(mozpath.join(manifest_dir,
|
||||
mozpath.basename(pattern)))
|
||||
installs.append((full, mozpath.join(install_root, pattern[1:])))
|
||||
else:
|
||||
full = mozpath.normpath(mozpath.join(manifest_dir, pattern))
|
||||
dest_path = mozpath.join(out_dir, pattern)
|
||||
|
||||
# If the path resolves to a different directory
|
||||
# tree, we take special behavior depending on the
|
||||
# entry type.
|
||||
if not full.startswith(manifest_dir):
|
||||
# If it's a support file, we install the file
|
||||
# into the current destination directory.
|
||||
# This implementation makes installing things
|
||||
# with custom prefixes impossible. If this is
|
||||
# needed, we can add support for that via a
|
||||
# special syntax later.
|
||||
if thing == 'support-files':
|
||||
dest_path = mozpath.join(out_dir,
|
||||
os.path.basename(pattern))
|
||||
# If it's not a support file, we ignore it.
|
||||
# This preserves old behavior so things like
|
||||
# head files doesn't get installed multiple
|
||||
# times.
|
||||
else:
|
||||
continue
|
||||
installs.append((full, mozpath.normpath(dest_path)))
|
||||
|
||||
return pattern_installs, installs, external
|
||||
|
||||
# Convenience methods for test manifest reading.
|
||||
def read_manifestparser_manifest(context, manifest_path):
|
||||
path = mozpath.normpath(mozpath.join(context.srcdir, manifest_path))
|
||||
|
|
Загрузка…
Ссылка в новой задаче