mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-02 18:08:58 +00:00
Bug 1645179 - Squash remaining dead code after removal of IMPACTED_TESTS r=ahal,froydnj
There is some remaining code in central originating from bug 1184405, which sought to associate source files with their "affected" test files. That ended up not panning out, and bug 1644228 removed a lot of that code, but left some remnants in the `Files` object which are still referenced in a couple different places. I'm deleting all of that code in `context.py` plus everything that references it for the following reasons: 1. Right now, `Files.{test_files,test_tags,test_flavors}` do get populated, but only ever with "default" values -- namely `moz.build` files that are above the files in question in the directory hierarchy. This is a heuristic that doesn't actually have anything to do with mapping source files to their corresponding test files, which is misleading. 2. Those attributes are accessed in two places. The first is in the `mach file-info dep-tests` command. This command isn't referenced anywhere else in tree and I don't have any evidence anyone ever uses it. Even if they do, I would claim that doing so is a mistake (because the results of the command aren't meaningful and are just populated by the "defaults" described above), and that person's workflow should be migrated to something else that *is* meaningful. 3. The second place where this metadata is accessed is in `testing/mozbase/moztest/moztest/resolve.py`; that method is invoked in `tools/tryselect/selectors/syntax.py`, but only if you pass `--detect-paths` to `mach try syntax`. This is [entirely broken](https://bugzilla.mozilla.org/show_bug.cgi?id=1614614), and even if we made an effort to fix it, it wouldn't do anything resembling what the documentation of `--detect-paths` suggests it would do (again, because the data isn't populated meaningfully). So I'm deleting the command line option entirely. Differential Revision: https://phabricator.services.mozilla.com/D79711
This commit is contained in:
parent
76a1d84247
commit
ce17cf368b
@ -1139,17 +1139,10 @@ class Files(SubContext):
|
||||
super(Files, self).__init__(parent)
|
||||
self.patterns = patterns
|
||||
self.finalized = set()
|
||||
self.test_files = set()
|
||||
self.test_tags = set()
|
||||
self.test_flavors = set()
|
||||
|
||||
def __iadd__(self, other):
|
||||
assert isinstance(other, Files)
|
||||
|
||||
self.test_files |= other.test_files
|
||||
self.test_tags |= other.test_tags
|
||||
self.test_flavors |= other.test_flavors
|
||||
|
||||
for k, v in other.items():
|
||||
if k == 'SCHEDULES' and 'SCHEDULES' in self:
|
||||
self['SCHEDULES'] = self['SCHEDULES'] | v
|
||||
|
@ -258,33 +258,6 @@ class MozbuildFileCommands(MachCommandBase):
|
||||
if missing_component:
|
||||
return 1
|
||||
|
||||
@SubCommand('file-info', 'dep-tests',
|
||||
'Show test files marked as dependencies of these source files.')
|
||||
@CommandArgument('-r', '--rev',
|
||||
help='Version control revision to look up info from')
|
||||
@CommandArgument('paths', nargs='+',
|
||||
help='Paths whose data to query')
|
||||
def file_info_test_deps(self, paths, rev=None):
|
||||
try:
|
||||
for p, m in self._get_files_info(paths, rev=rev).items():
|
||||
print('%s:' % mozpath.relpath(p, self.topsrcdir))
|
||||
if m.test_files:
|
||||
print('\tTest file patterns:')
|
||||
for p in m.test_files:
|
||||
print('\t\t%s' % p)
|
||||
if m.test_tags:
|
||||
print('\tRelevant tags:')
|
||||
for p in m.test_tags:
|
||||
print('\t\t%s' % p)
|
||||
if m.test_flavors:
|
||||
print('\tRelevant flavors:')
|
||||
for p in m.test_flavors:
|
||||
print('\t\t%s' % p)
|
||||
|
||||
except InvalidPathException as e:
|
||||
print(e.message)
|
||||
return 1
|
||||
|
||||
def _get_files_info(self, paths, rev=None):
|
||||
reader = self.mozbuild_reader(config_mode='empty', vcs_revision=rev)
|
||||
|
||||
|
@ -45,12 +45,6 @@ from mozbuild.util import (
|
||||
ReadOnlyDefaultDict,
|
||||
)
|
||||
|
||||
from mozbuild.testing import (
|
||||
TEST_MANIFESTS,
|
||||
REFTEST_FLAVORS,
|
||||
WEB_PLATFORM_TESTS_FLAVORS,
|
||||
)
|
||||
|
||||
from mozbuild.backend.configenvironment import ConfigEnvironment
|
||||
|
||||
from mozpack.files import FileFinder
|
||||
@ -1351,20 +1345,6 @@ class BuildReader(object):
|
||||
"""
|
||||
paths, _ = self.read_relevant_mozbuilds(paths)
|
||||
|
||||
# For thousands of inputs (say every file in a sub-tree),
|
||||
# test_defaults_for_path() gets called with the same contexts multiple
|
||||
# times (once for every path in a directory that doesn't have any
|
||||
# test metadata). So, we cache the function call.
|
||||
defaults_cache = {}
|
||||
|
||||
def test_defaults_for_path(ctxs):
|
||||
key = tuple(ctx.current_path or ctx.main_path for ctx in ctxs)
|
||||
|
||||
if key not in defaults_cache:
|
||||
defaults_cache[key] = self.test_defaults_for_path(ctxs)
|
||||
|
||||
return defaults_cache[key]
|
||||
|
||||
r = {}
|
||||
|
||||
# Only do wildcard matching if the '*' character is present.
|
||||
@ -1401,40 +1381,6 @@ class BuildReader(object):
|
||||
if any(path_matches_pattern(relpath, p) for p in ctx.patterns):
|
||||
flags += ctx
|
||||
|
||||
if not any([flags.test_tags, flags.test_files, flags.test_flavors]):
|
||||
flags += test_defaults_for_path(ctxs)
|
||||
|
||||
r[path] = flags
|
||||
|
||||
return r
|
||||
|
||||
def test_defaults_for_path(self, ctxs):
|
||||
# This names the context keys that will end up emitting a test
|
||||
# manifest.
|
||||
test_manifest_contexts = set(
|
||||
['%s_MANIFESTS' % key for key in TEST_MANIFESTS] +
|
||||
['%s_MANIFESTS' % flavor.upper() for flavor in REFTEST_FLAVORS] +
|
||||
['%s_MANIFESTS' % flavor.upper().replace('-', '_')
|
||||
for flavor in WEB_PLATFORM_TESTS_FLAVORS]
|
||||
)
|
||||
|
||||
result_context = Files(Context())
|
||||
for ctx in ctxs:
|
||||
for key in ctx:
|
||||
if key not in test_manifest_contexts:
|
||||
continue
|
||||
for paths, obj in ctx[key]:
|
||||
if isinstance(paths, tuple):
|
||||
path, tests_root = paths
|
||||
tests_root = mozpath.join(ctx.relsrcdir, tests_root)
|
||||
for t in (mozpath.join(tests_root, it[0]) for it in obj):
|
||||
result_context.test_files.add(mozpath.dirname(t) + '/**')
|
||||
else:
|
||||
for t in obj.tests:
|
||||
if 'relpath' in t:
|
||||
relpath = t['relpath']
|
||||
else:
|
||||
relpath = mozpath.relpath(t['path'],
|
||||
self.config.topsrcdir)
|
||||
result_context.test_files.add(mozpath.dirname(relpath) + '/**')
|
||||
return result_context
|
||||
|
@ -850,24 +850,6 @@ class TestResolver(MozbuildObject):
|
||||
else:
|
||||
yield test
|
||||
|
||||
def get_outgoing_metadata(self):
|
||||
paths, tags, flavors = set(), set(), set()
|
||||
changed_files = self.repository.get_outgoing_files('AM')
|
||||
if changed_files:
|
||||
reader = self.mozbuild_reader(config_mode='empty')
|
||||
files_info = reader.files_info(changed_files)
|
||||
|
||||
for path, info in six.iteritems(files_info):
|
||||
paths |= info.test_files
|
||||
tags |= info.test_tags
|
||||
flavors |= info.test_flavors
|
||||
|
||||
return {
|
||||
'paths': paths,
|
||||
'tags': tags,
|
||||
'flavors': flavors,
|
||||
}
|
||||
|
||||
def resolve_metadata(self, what):
|
||||
"""Resolve tests based on the given metadata. If not specified, metadata
|
||||
from outgoing files will be used instead.
|
||||
|
@ -74,12 +74,6 @@ class SyntaxParser(BaseTryParser):
|
||||
'help': 'Print detailed information about the resulting test selection '
|
||||
'and commands performed.',
|
||||
}],
|
||||
[['--detect-paths'],
|
||||
{'dest': 'detect_paths',
|
||||
'action': 'store_true',
|
||||
'default': False,
|
||||
'help': 'Provide test paths based on files changed in the working copy.',
|
||||
}],
|
||||
]
|
||||
|
||||
# Arguments we will accept on the command line and pass through to try
|
||||
@ -547,13 +541,8 @@ class AutoTry(object):
|
||||
|
||||
def run(self, **kwargs):
|
||||
if not any(kwargs[item] for item in ("paths", "tests", "tags")):
|
||||
if kwargs['detect_paths']:
|
||||
res = self.resolver.get_outgoing_metadata()
|
||||
kwargs['paths'] = res['paths']
|
||||
kwargs['tags'] = res['tags']
|
||||
else:
|
||||
kwargs['paths'] = set()
|
||||
kwargs['tags'] = set()
|
||||
kwargs['paths'] = set()
|
||||
kwargs['tags'] = set()
|
||||
|
||||
builds, platforms, tests, talos, jobs, paths, tags, extra = self.validate_args(**kwargs)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user