Bug 1866176 - normalize paths in FileFinder r=ahal,firefox-build-system-reviewers,glandium

On Windows, paths provided to FileFinder may contain backslashes, which
will cause uses of `mozpath.match` later on to fail when they try to
compare mixed-path values. To avoid this, normalize those paths on
receipt.

(Also, silence a lint by pulling the global `args` variable into a
function, so that it is no longer occluded by the various function
parameters named `args`.)

Differential Revision: https://phabricator.services.mozilla.com/D194448
This commit is contained in:
Ray Kraesig
2023-12-04 17:14:29 +00:00
parent 6ae9f470d2
commit 29050fe320
3 changed files with 15 additions and 9 deletions

View File

@@ -844,15 +844,17 @@ class BuildReader(object):
"obj*",
}
# Also ignore any other directories that could be objdirs, but don't
# necessarily start with the string 'obj'.
objdir_finder = FileFinder(self.config.topsrcdir, ignore=ignores)
for path, _file in objdir_finder.find("*/config.status"):
ignores.add(os.path.dirname(path))
del objdir_finder
self._relevant_mozbuild_finder = FileFinder(
self.config.topsrcdir, ignore=ignores
)
# Also ignore any other directories that could be objdirs, they don't
# necessarily start with the string 'obj'.
for path, f in self._relevant_mozbuild_finder.find("*/config.status"):
self._relevant_mozbuild_finder.ignore.add(os.path.dirname(path))
max_workers = cpu_count()
if sys.platform.startswith("win"):
# In python 3, on Windows, ProcessPoolExecutor uses

View File

@@ -834,7 +834,7 @@ class BaseFinder(object):
if minify_js and not minify:
raise ValueError("minify_js requires minify.")
self.base = base
self.base = mozpath.normsep(base)
self._minify = minify
self._minify_js = minify_js
self._minify_js_verify_command = minify_js_verify_command
@@ -964,7 +964,7 @@ class FileFinder(BaseFinder):
BaseFinder.__init__(self, base, **kargs)
self.find_dotfiles = find_dotfiles
self.find_executables = find_executables
self.ignore = ignore
self.ignore = tuple(mozpath.normsep(path) for path in ignore)
self.ignore_broken_symlinks = ignore_broken_symlinks
def _find(self, pattern):

View File

@@ -438,7 +438,11 @@ def run(
return result.returncode
if __name__ == "__main__":
def main() -> int:
parser = MozlintParser()
args = vars(parser.parse_args())
sys.exit(run(**args))
return run(**args)
if __name__ == "__main__":
sys.exit(main())