зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1335309 - Add explicit find_executables arguments to every use of FileFinder. r=mshal
And make it an error not to give it. While the default is True, we do pass a value of False wherever it makes sense, which happens to be, in most places. This is an intermediate step to flip the default from True to False, ensuring that we don't unwantedly switch some calls to False. --HG-- extra : rebase_source : 432e03f032fef378af482581685583262e5d2661
This commit is contained in:
Родитель
3b9ffa7593
Коммит
dbdbf959b8
|
@ -102,7 +102,7 @@ def main(args):
|
|||
if not opts.resources:
|
||||
continue
|
||||
resources = os.path.abspath(opts.resources)
|
||||
finder = FileFinder(resources)
|
||||
finder = FileFinder(resources, find_executables=False)
|
||||
matches = [p for p, _ in finder.find(drawables_template.format(name=name))]
|
||||
if not matches:
|
||||
raise Exception("Could not find drawable in '{resources}' for '{name}'"
|
||||
|
|
|
@ -28,7 +28,7 @@ def main(args):
|
|||
jarrer = Jarrer(optimize=False)
|
||||
|
||||
with errors.accumulate():
|
||||
finder = FileFinder(args.C)
|
||||
finder = FileFinder(args.C, find_executables=False)
|
||||
for path in args.input:
|
||||
for p, f in finder.find(path):
|
||||
jarrer.add(p, f)
|
||||
|
|
|
@ -247,7 +247,7 @@ class AndroidEclipseBackend(CommonBackend):
|
|||
defines['MOZ_ANDROID_MIN_SDK_VERSION'] = self.environment.defines['MOZ_ANDROID_MIN_SDK_VERSION']
|
||||
|
||||
copier = FileCopier()
|
||||
finder = FileFinder(template_directory)
|
||||
finder = FileFinder(template_directory, find_executables=False)
|
||||
for input_filename, f in itertools.chain(finder.find('**'), finder.find('.**')):
|
||||
if input_filename == 'AndroidManifest.xml' and not data.is_library:
|
||||
# Main projects supply their own manifests.
|
||||
|
|
|
@ -15,7 +15,7 @@ def package_gcno_tree(root, output_file):
|
|||
if isinstance(root, unicode):
|
||||
root = root.encode('utf-8')
|
||||
|
||||
finder = FileFinder(root)
|
||||
finder = FileFinder(root, find_executables=False)
|
||||
jarrer = Jarrer(optimize=False)
|
||||
for p, f in finder.find("**/*.gcno"):
|
||||
jarrer.add(p, f)
|
||||
|
|
|
@ -152,7 +152,7 @@ class TestBuild(unittest.TestCase):
|
|||
# of the difference in type.
|
||||
result = {
|
||||
p: f.open().read().decode('utf-8')
|
||||
for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist'))
|
||||
for p, f in FileFinder(mozpath.join(config.topobjdir, 'dist'), find_executables=False)
|
||||
}
|
||||
self.assertTrue(len(result))
|
||||
self.assertEqual(result, {
|
||||
|
|
|
@ -841,7 +841,7 @@ class FileFinder(BaseFinder):
|
|||
'''
|
||||
Helper to get appropriate BaseFile instances from the file system.
|
||||
'''
|
||||
def __init__(self, base, find_executables=True, ignore=(),
|
||||
def __init__(self, base, ignore=(),
|
||||
find_dotfiles=False, **kargs):
|
||||
'''
|
||||
Create a FileFinder for files under the given base directory.
|
||||
|
@ -856,6 +856,8 @@ class FileFinder(BaseFinder):
|
|||
to a directory, all files under that directory will be ignored. If
|
||||
an entry corresponds to a file, that particular file will be ignored.
|
||||
'''
|
||||
assert 'find_executables' in kargs
|
||||
find_executables = kargs.pop('find_executables')
|
||||
BaseFinder.__init__(self, base, **kargs)
|
||||
self.find_dotfiles = find_dotfiles
|
||||
self.find_executables = find_executables
|
||||
|
|
|
@ -47,7 +47,7 @@ class UnpackFinder(BaseFinder):
|
|||
if isinstance(source, BaseFinder):
|
||||
self._finder = source
|
||||
else:
|
||||
self._finder = FileFinder(source)
|
||||
self._finder = FileFinder(source, find_executables=False)
|
||||
self.base = self._finder.base
|
||||
self.files = FileRegistry()
|
||||
self.kind = 'flat'
|
||||
|
|
|
@ -924,13 +924,13 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
|
||||
def test_file_finder(self):
|
||||
self.prepare_match_test(with_dotfiles=True)
|
||||
self.finder = FileFinder(self.tmpdir)
|
||||
self.finder = FileFinder(self.tmpdir, find_executables=False)
|
||||
self.do_match_test()
|
||||
self.do_finder_test(self.finder)
|
||||
|
||||
def test_get(self):
|
||||
self.prepare_match_test()
|
||||
finder = FileFinder(self.tmpdir)
|
||||
finder = FileFinder(self.tmpdir, find_executables=False)
|
||||
|
||||
self.assertIsNone(finder.get('does-not-exist'))
|
||||
res = finder.get('bar')
|
||||
|
@ -946,7 +946,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
# Present to ensure prefix matching doesn't exclude.
|
||||
self.add('foo/quxz')
|
||||
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux'])
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux'], find_executables=False)
|
||||
|
||||
self.do_check('**', ['bar', 'foo/bar', 'foo/baz', 'foo/quxz', 'fooz'])
|
||||
self.do_check('foo/*', ['foo/bar', 'foo/baz', 'foo/quxz'])
|
||||
|
@ -964,7 +964,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
# Be sure prefix match doesn't get ignored.
|
||||
self.add('barz')
|
||||
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'])
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/bar', 'bar'], find_executables=False)
|
||||
self.do_check('**', ['barz', 'foo/baz', 'foo/qux/1', 'foo/qux/2/test',
|
||||
'foo/qux/2/test2', 'foo/qux/bar'])
|
||||
self.do_check('foo/**', ['foo/baz', 'foo/qux/1', 'foo/qux/2/test',
|
||||
|
@ -976,14 +976,14 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
|
||||
self.add('foo/quxz')
|
||||
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'])
|
||||
self.finder = FileFinder(self.tmpdir, ignore=['foo/qux/*'], find_executables=False)
|
||||
self.do_check('**', ['foo/bar', 'foo/baz', 'foo/quxz', 'bar'])
|
||||
self.do_check('foo/**', ['foo/bar', 'foo/baz', 'foo/quxz'])
|
||||
|
||||
def test_dotfiles(self):
|
||||
"""Finder can find files beginning with . is configured."""
|
||||
self.prepare_match_test(with_dotfiles=True)
|
||||
self.finder = FileFinder(self.tmpdir, find_dotfiles=True)
|
||||
self.finder = FileFinder(self.tmpdir, find_dotfiles=True, find_executables=False)
|
||||
self.do_check('**', ['bar', 'foo/.foo', 'foo/.bar/foo',
|
||||
'foo/bar', 'foo/baz', 'foo/qux/1', 'foo/qux/bar',
|
||||
'foo/qux/2/test', 'foo/qux/2/test2'])
|
||||
|
@ -991,7 +991,7 @@ class TestFileFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
def test_dotfiles_plus_ignore(self):
|
||||
self.prepare_match_test(with_dotfiles=True)
|
||||
self.finder = FileFinder(self.tmpdir, find_dotfiles=True,
|
||||
ignore=['foo/.bar/**'])
|
||||
ignore=['foo/.bar/**'], find_executables=False)
|
||||
self.do_check('foo/**', ['foo/.foo', 'foo/bar', 'foo/baz',
|
||||
'foo/qux/1', 'foo/qux/bar', 'foo/qux/2/test', 'foo/qux/2/test2'])
|
||||
|
||||
|
@ -1060,8 +1060,8 @@ class TestComposedFinder(MatchTestTemplate, TestWithTmpDir):
|
|||
open(self.tmppath('a/foo/qux/hoge'), 'wb').write('hoge')
|
||||
open(self.tmppath('a/foo/qux/bar'), 'wb').write('not the right content')
|
||||
self.finder = ComposedFinder({
|
||||
'': FileFinder(self.tmppath('a')),
|
||||
'foo/qux': FileFinder(self.tmppath('b')),
|
||||
'': FileFinder(self.tmppath('a'), find_executables=False),
|
||||
'foo/qux': FileFinder(self.tmppath('b'), find_executables=False),
|
||||
})
|
||||
self.do_match_test()
|
||||
|
||||
|
|
|
@ -245,7 +245,7 @@ class TestJar(unittest.TestCase):
|
|||
def test_add_from_finder(self):
|
||||
s = MockDest()
|
||||
with JarWriter(fileobj=s, optimize=self.optimize) as jar:
|
||||
finder = FileFinder(test_data_path)
|
||||
finder = FileFinder(test_data_path, find_executables=False)
|
||||
for p, f in finder.find('test_data'):
|
||||
jar.add('test_data', f)
|
||||
|
||||
|
|
|
@ -46,8 +46,8 @@ class TestUnifiedFinder(TestUnified):
|
|||
self.create_one('b', 'test/foo', 'b\nc\na\n')
|
||||
self.create_both('test/bar', 'a\nb\nc\n')
|
||||
|
||||
finder = UnifiedFinder(FileFinder(self.tmppath('a')),
|
||||
FileFinder(self.tmppath('b')),
|
||||
finder = UnifiedFinder(FileFinder(self.tmppath('a'), find_executables=False),
|
||||
FileFinder(self.tmppath('b'), find_executables=False),
|
||||
sorted=['test'])
|
||||
self.assertEqual(sorted([(f, c.open().read())
|
||||
for f, c in finder.find('foo')]),
|
||||
|
@ -63,8 +63,8 @@ class TestUnifiedFinder(TestUnified):
|
|||
|
||||
class TestUnifiedBuildFinder(TestUnified):
|
||||
def test_unified_build_finder(self):
|
||||
finder = UnifiedBuildFinder(FileFinder(self.tmppath('a')),
|
||||
FileFinder(self.tmppath('b')))
|
||||
finder = UnifiedBuildFinder(FileFinder(self.tmppath('a'), find_executables=False),
|
||||
FileFinder(self.tmppath('b'), find_executables=False))
|
||||
|
||||
# Test chrome.manifest unification
|
||||
self.create_both('chrome.manifest', 'a\nb\nc\n')
|
||||
|
|
|
@ -342,11 +342,14 @@ def main():
|
|||
'js-compare-ast.js')
|
||||
]
|
||||
if args.unify:
|
||||
finder = UnifiedBuildFinder(FileFinder(args.source),
|
||||
FileFinder(args.unify),
|
||||
finder = UnifiedBuildFinder(FileFinder(args.source,
|
||||
find_executables=True),
|
||||
FileFinder(args.unify,
|
||||
find_executables=True),
|
||||
**finder_args)
|
||||
else:
|
||||
finder = FileFinder(args.source, **finder_args)
|
||||
finder = FileFinder(args.source, find_executables=True,
|
||||
**finder_args)
|
||||
if 'NO_PKG_FILES' in os.environ:
|
||||
sinkformatter = NoPkgFilesRemover(formatter,
|
||||
args.manifest is not None)
|
||||
|
|
|
@ -15,7 +15,7 @@ def strip(dir):
|
|||
# The FileFinder will give use ExecutableFile instances for files
|
||||
# that can be stripped, and copying ExecutableFiles defaults to
|
||||
# stripping them unless buildconfig.substs['PKG_SKIP_STRIP'] is set.
|
||||
for p, f in FileFinder(dir):
|
||||
for p, f in FileFinder(dir, find_executables=True):
|
||||
copier.add(p, f)
|
||||
copier.copy(dir)
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче