Backed out changeset 8b2c3a0fa051 (bug 1612077) lint failures on test_support_files.py. CLOSED TREE

This commit is contained in:
Narcis Beleuzu 2020-03-02 19:38:08 +02:00
Родитель 7876310747
Коммит 0543d20741
2 изменённых файлов: 7 добавлений и 16 удалений

Просмотреть файл

@ -202,20 +202,17 @@ class LintRoller(object):
return 0
def _generate_jobs(self, paths, vcs_paths, num_procs):
def __get_current_paths(path=self.root):
return [os.path.join(path, p) for p in os.listdir(path)]
"""A job is of the form (<linter:dict>, <paths:list>)."""
for linter in self.linters:
if any(os.path.isfile(p) and mozpath.match(p, pattern)
for pattern in linter.get('support-files', []) for p in vcs_paths):
lpaths = __get_current_paths()
lpaths = [self.root]
print("warning: {} support-file modified, linting entire tree "
"(press ctrl-c to cancel)".format(linter['name']))
else:
lpaths = paths.union(vcs_paths)
lpaths = list(lpaths) or __get_current_paths(os.getcwd())
lpaths = list(lpaths) or [os.getcwd()]
chunk_size = min(self.MAX_PATHS_PER_JOB, int(ceil(len(lpaths) / num_procs))) or 1
if linter['type'] == 'global':
# Global linters lint the entire tree in one job.

Просмотреть файл

@ -14,7 +14,6 @@ import pytest
from mozlint.errors import LintersNotConfigured
from mozlint.result import Issue, ResultSummary
from itertools import chain
here = os.path.abspath(os.path.dirname(__file__))
@ -239,7 +238,7 @@ def test_keyboard_interrupt():
assert 'Traceback' not in out
def test_support_files(lint, linters, filedir, monkeypatch, files):
def test_support_files(lint, linters, filedir, monkeypatch):
jobs = []
# Replace the original _generate_jobs with a new one that simply
@ -254,32 +253,27 @@ def test_support_files(lint, linters, filedir, monkeypatch, files):
linter_path = linters('support_files')[0]
lint.read(linter_path)
lint.root = filedir
# Modified support files only lint entire root if --outgoing or --workdir
# are used.
path = os.path.join(filedir, 'foobar.js')
lint.mock_vcs([os.path.join(filedir, 'foobar.py')])
lint.roll(path)
actual_files = sorted(chain(*jobs))
assert actual_files == [path]
assert jobs[0] == [path]
jobs = []
lint.roll(path, workdir=True)
actual_files = sorted(chain(*jobs))
assert actual_files == files
assert jobs[0] == [lint.root]
jobs = []
lint.roll(path, outgoing=True)
actual_files = sorted(chain(*jobs))
assert actual_files == files
assert jobs[0] == [lint.root]
# Lint config file is implicitly added as a support file
lint.mock_vcs([linter_path])
jobs = []
lint.roll(path, outgoing=True, workdir=True)
actual_files = sorted(chain(*jobs))
assert actual_files == files
assert jobs[0] == [lint.root]
def test_setup(lint, linters, filedir, capfd):