зеркало из https://github.com/mozilla/gecko-dev.git
Merge mozilla-central to fx-team on a CLOSED TREE
This commit is contained in:
Коммит
84e10fced2
|
@ -6,7 +6,6 @@ import json
|
|||
|
||||
from ..result import ResultEncoder
|
||||
from .stylish import StylishFormatter
|
||||
from .treeherder import TreeherderFormatter
|
||||
|
||||
|
||||
class JSONFormatter(object):
|
||||
|
@ -17,7 +16,6 @@ class JSONFormatter(object):
|
|||
all_formatters = {
|
||||
'json': JSONFormatter,
|
||||
'stylish': StylishFormatter,
|
||||
'treeherder': TreeherderFormatter,
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,30 +0,0 @@
|
|||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from ..result import ResultContainer
|
||||
|
||||
|
||||
class TreeherderFormatter(object):
|
||||
"""Formatter for treeherder friendly output.
|
||||
|
||||
This formatter looks ugly, but prints output such that
|
||||
treeherder is able to highlight the errors and warnings.
|
||||
This is a stop-gap until bug 1276486 is fixed.
|
||||
"""
|
||||
fmt = "TEST-UNEXPECTED-{level} | {path}:{lineno}:{column} | {message} ({rule})"
|
||||
|
||||
def __call__(self, result):
|
||||
message = []
|
||||
for path, errors in sorted(result.iteritems()):
|
||||
for err in errors:
|
||||
assert isinstance(err, ResultContainer)
|
||||
|
||||
d = {s: getattr(err, s) for s in err.__slots__}
|
||||
d['level'] = d['level'].upper()
|
||||
d['rule'] = d['rule'] or d['linter']
|
||||
message.append(self.fmt.format(**d))
|
||||
|
||||
return "\n".join(message)
|
|
@ -42,7 +42,7 @@ def _run_linters(queue, paths, **lintargs):
|
|||
func = supported_types[linter['type']]
|
||||
res = func(paths, linter, **lintargs) or []
|
||||
|
||||
if not isinstance(res, (list, tuple)):
|
||||
if isinstance(res, basestring):
|
||||
continue
|
||||
|
||||
for r in res:
|
||||
|
|
|
@ -68,16 +68,6 @@ d/e/f.txt
|
|||
fmt = formatters.get('stylish', disable_colors=True)
|
||||
self.assertEqual(expected, fmt(self.results))
|
||||
|
||||
def test_treeherder_formatter(self):
|
||||
expected = """
|
||||
TEST-UNEXPECTED-ERROR | a/b/c.txt:1:1 | oh no foo (foo)
|
||||
TEST-UNEXPECTED-ERROR | a/b/c.txt:4:1 | oh no baz (baz)
|
||||
TEST-UNEXPECTED-WARNING | d/e/f.txt:4:2 | oh no bar (bar-not-allowed)
|
||||
""".strip()
|
||||
|
||||
fmt = formatters.get('treeherder')
|
||||
self.assertEqual(expected, fmt(self.results))
|
||||
|
||||
def test_json_formatter(self):
|
||||
fmt = formatters.get('json')
|
||||
formatted = json.loads(fmt(self.results))
|
||||
|
|
|
@ -13,18 +13,11 @@ apt_packages=()
|
|||
apt_packages+=('curl')
|
||||
apt_packages+=('mercurial')
|
||||
apt_packages+=('python')
|
||||
apt_packages+=('python-pip')
|
||||
apt_packages+=('sudo')
|
||||
apt_packages+=('xz-utils')
|
||||
|
||||
apt-get update
|
||||
apt-get install -y ${apt_packages[@]}
|
||||
|
||||
# Without this we get spurious "LC_ALL: cannot change locale (en_US.UTF-8)" errors,
|
||||
# and python scripts raise UnicodeEncodeError when trying to print unicode characters.
|
||||
locale-gen en_US.UTF-8
|
||||
dpkg-reconfigure locales
|
||||
|
||||
tooltool_fetch() {
|
||||
cat >manifest.tt
|
||||
/build/tooltool.py fetch
|
||||
|
@ -68,19 +61,5 @@ tooltool_fetch <<'EOF'
|
|||
EOF
|
||||
npm install -g taskcluster-vcs-v2.3.12.tar.gz
|
||||
|
||||
|
||||
###
|
||||
# Flake8 Setup
|
||||
###
|
||||
|
||||
cat >requirements.txt <<'EOF'
|
||||
mccabe==0.4.0 --hash=sha256:cbc2938f6c01061bc6d21d0c838c2489664755cb18676f0734d7617f4577d09e
|
||||
pep8==1.7.0 --hash=sha256:4fc2e478addcf17016657dff30b2d8d611e8341fac19ccf2768802f6635d7b8a
|
||||
pyflakes==1.2.3 --hash=sha256:e87bac26c62ea5b45067cc89e4a12f56e1483f1f2cda17e7c9b375b9fd2f40da
|
||||
flake8==2.5.4 --hash=sha256:fb5a67af4024622287a76abf6b7fe4fb3cfacf765a790976ce64f52c44c88e4a
|
||||
EOF
|
||||
|
||||
pip install --require-hashes -r requirements.txt
|
||||
|
||||
cd /
|
||||
rm -rf /setup
|
||||
|
|
|
@ -526,16 +526,6 @@ tasks:
|
|||
# Other misc lint related files.
|
||||
- 'tools/lint/**'
|
||||
- 'testing/docker/lint/**'
|
||||
flake8-gecko:
|
||||
task: tasks/tests/mozlint-flake8.yml
|
||||
root: true
|
||||
when:
|
||||
file_patterns:
|
||||
- '**/*.py'
|
||||
- '**/.flake8'
|
||||
- 'python/mozlint/**'
|
||||
- 'tools/lint/**'
|
||||
- 'testing/docker/lint/**'
|
||||
android-api-15-gradle-dependencies:
|
||||
task: tasks/builds/android_api_15_gradle_dependencies.yml
|
||||
root: true
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
---
|
||||
$inherits:
|
||||
from: 'tasks/lint.yml'
|
||||
variables:
|
||||
build_product: 'lint'
|
||||
build_name: 'flake8-gecko'
|
||||
build_type: 'opt'
|
||||
|
||||
task:
|
||||
metadata:
|
||||
name: '[TC] - Flake8'
|
||||
description: 'Python flake8 linter'
|
||||
payload:
|
||||
image:
|
||||
type: 'task-image'
|
||||
path: 'public/image.tar'
|
||||
taskId: '{{#task_id_for_image}}lint{{/task_id_for_image}}'
|
||||
command:
|
||||
- bash
|
||||
- -cx
|
||||
- >
|
||||
tc-vcs checkout ./gecko {{base_repository}} {{head_repository}} {{head_rev}} {{head_ref}} &&
|
||||
cd gecko &&
|
||||
./mach lint -l flake8 -f treeherder
|
||||
extra:
|
||||
locations:
|
||||
build: null
|
||||
tests: null
|
||||
treeherder:
|
||||
machine:
|
||||
platform: lint
|
||||
groupSymbol: tc
|
||||
symbol: f8
|
||||
tier: 2
|
||||
treeherderEnv:
|
||||
- production
|
||||
- staging
|
|
@ -74,7 +74,7 @@ def lint(files, **lintargs):
|
|||
|
||||
if not binary:
|
||||
print(FLAKE8_NOT_FOUND)
|
||||
return []
|
||||
return 1
|
||||
|
||||
cmdargs = [
|
||||
binary,
|
||||
|
|
|
@ -55,13 +55,8 @@ class MachCommands(MachCommandBase):
|
|||
# run all linters
|
||||
results = lint.roll(paths)
|
||||
|
||||
status = 0
|
||||
if results:
|
||||
status = 1
|
||||
|
||||
formatter = formatters.get(fmt)
|
||||
print(formatter(results))
|
||||
return status
|
||||
|
||||
@SubCommand('lint', 'setup',
|
||||
"Setup required libraries for specified lints.")
|
||||
|
|
Загрузка…
Ссылка в новой задаче