Expand tidy to lint parts of /tests/wpt

This commit is contained in:
Corey Farwell 2015-11-03 17:11:44 -05:00
parent 1e3010e4cd
commit d1824aea48
8 changed files with 35 additions and 19 deletions

View file

@ -23,7 +23,10 @@ reftest_filetype = ".list"
ignored_files = [ ignored_files = [
# Upstream # Upstream
os.path.join(".", "support", "*"), os.path.join(".", "support", "*"),
os.path.join(".", "tests", "wpt", "*"), os.path.join(".", "tests", "wpt", "css-tests", "*"),
os.path.join(".", "tests", "wpt", "harness", "*"),
os.path.join(".", "tests", "wpt", "update", "*"),
os.path.join(".", "tests", "wpt", "web-platform-tests", "*"),
os.path.join(".", "python", "mach", "*"), os.path.join(".", "python", "mach", "*"),
os.path.join(".", "components", "script", "dom", "bindings", "codegen", "parser", "*"), os.path.join(".", "components", "script", "dom", "bindings", "codegen", "parser", "*"),
os.path.join(".", "components", "script", "dom", "bindings", "codegen", "ply", "*"), os.path.join(".", "components", "script", "dom", "bindings", "codegen", "ply", "*"),

View file

@ -4,10 +4,10 @@
from mozlog.formatters import base from mozlog.formatters import base
import collections import collections
import mozlog.commandline
import os import os
import sys import sys
class GroupingFormatter(base.BaseFormatter): class GroupingFormatter(base.BaseFormatter):
"""Formatter designed to produce unexpected test results grouped """Formatter designed to produce unexpected test results grouped
together in a readable format.""" together in a readable format."""
@ -22,7 +22,7 @@ class GroupingFormatter(base.BaseFormatter):
self.tests_with_failing_subtests = [] self.tests_with_failing_subtests = []
self.interactive = os.isatty(sys.stdout.fileno()) self.interactive = os.isatty(sys.stdout.fileno())
self.expected = { self.expected = {
'OK': 0, 'OK': 0,
'PASS': 0, 'PASS': 0,
'FAIL': 0, 'FAIL': 0,
@ -32,7 +32,7 @@ class GroupingFormatter(base.BaseFormatter):
'CRASH': 0, 'CRASH': 0,
} }
self.unexpected_tests = { self.unexpected_tests = {
'OK': [], 'OK': [],
'PASS': [], 'PASS': [],
'FAIL': [], 'FAIL': [],
@ -54,7 +54,7 @@ class GroupingFormatter(base.BaseFormatter):
output = self.text_to_erase_display() output = self.text_to_erase_display()
if text: if text:
output += text output += text
if new_display != None: if new_display is not None:
self.current_display = new_display self.current_display = new_display
return output + self.current_display return output + self.current_display
@ -235,7 +235,7 @@ class GroupingFormatter(base.BaseFormatter):
# We are logging messages that begin with STDERR, because that is how exceptions # We are logging messages that begin with STDERR, because that is how exceptions
# in this formatter are indicated. # in this formatter are indicated.
if data['message'].startswith('STDERR'): if data['message'].startswith('STDERR'):
return self.generate_output(text=data['message']+"\n") return self.generate_output(text=data['message'] + "\n")
if data['level'] in ('CRITICAL', 'ERROR'): if data['level'] in ('CRITICAL', 'ERROR'):
return self.generate_output(text=data['message']+"\n") return self.generate_output(text=data['message'] + "\n")

View file

@ -1,3 +1,8 @@
# 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/.
def main(request, response): def main(request, response):
output = '\x1b\x03)\x00\xa4\xcc\xde\xe2\xb3 vA\x00\x0c' output = '\x1b\x03)\x00\xa4\xcc\xde\xe2\xb3 vA\x00\x0c'
headers = [("Content-type", "text/plain"), headers = [("Content-type", "text/plain"),

View file

@ -2,7 +2,6 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import argparse
import multiprocessing import multiprocessing
import os import os
import sys import sys
@ -12,9 +11,11 @@ import grouping_formatter
here = os.path.split(__file__)[0] here = os.path.split(__file__)[0]
servo_root = os.path.abspath(os.path.join(here, "..", "..")) servo_root = os.path.abspath(os.path.join(here, "..", ".."))
def wpt_path(*args): def wpt_path(*args):
return os.path.join(here, *args) return os.path.join(here, *args)
def servo_path(*args): def servo_path(*args):
return os.path.join(servo_root, *args) return os.path.join(servo_root, *args)
@ -22,6 +23,7 @@ def servo_path(*args):
sys.path.append(wpt_path("harness")) sys.path.append(wpt_path("harness"))
from wptrunner import wptrunner, wptcommandline from wptrunner import wptrunner, wptcommandline
def run_tests(paths=None, **kwargs): def run_tests(paths=None, **kwargs):
if paths is None: if paths is None:
paths = {} paths = {}
@ -34,6 +36,7 @@ def run_tests(paths=None, **kwargs):
success = wptrunner.run_tests(**kwargs) success = wptrunner.run_tests(**kwargs)
return 0 if success else 1 return 0 if success else 1
def set_defaults(paths, kwargs): def set_defaults(paths, kwargs):
if kwargs["product"] is None: if kwargs["product"] is None:
kwargs["product"] = "servo" kwargs["product"] = "servo"
@ -57,6 +60,7 @@ def set_defaults(paths, kwargs):
wptcommandline.check_args(kwargs) wptcommandline.check_args(kwargs)
def main(paths=None): def main(paths=None):
parser = wptcommandline.create_parser() parser = wptcommandline.create_parser()
kwargs = vars(parser.parse_args()) kwargs = vars(parser.parse_args())

View file

@ -2,16 +2,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/env python
import run import run
import sys
paths = {"include_manifest": run.wpt_path("include_css.ini"), paths = {"include_manifest": run.wpt_path("include_css.ini"),
"config": run.wpt_path("config_css.ini")} "config": run.wpt_path("config_css.ini")}
def run_tests(**kwargs): def run_tests(**kwargs):
return run.run_tests(paths=paths, **kwargs) return run.run_tests(paths=paths, **kwargs)
def main(): def main():
return run.main(paths) return run.main(paths)

View file

@ -2,16 +2,17 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/env python
import run import run
import sys
paths = {"include_manifest": run.wpt_path("include.ini"), paths = {"include_manifest": run.wpt_path("include.ini"),
"config": run.wpt_path("config.ini")} "config": run.wpt_path("config.ini")}
def run_tests(**kwargs): def run_tests(**kwargs):
return run.run_tests(paths=paths, **kwargs) return run.run_tests(paths=paths, **kwargs)
def main(): def main():
return run.main(paths) return run.main(paths)

View file

@ -2,21 +2,20 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/env python
import argparse
import multiprocessing
import os import os
import sys import sys
from wptrunner import wptcommandline
here = os.path.split(__file__)[0] here = os.path.split(__file__)[0]
def wpt_path(*args): def wpt_path(*args):
return os.path.join(here, *args) return os.path.join(here, *args)
# Imports # Imports
from update import updatecommandline from update import updatecommandline
def update_tests(**kwargs): def update_tests(**kwargs):
import update import update
@ -26,11 +25,13 @@ def update_tests(**kwargs):
rv = update.run_update(logger, **kwargs) rv = update.run_update(logger, **kwargs)
return 0 if rv is update.exit_unclean else 1 return 0 if rv is update.exit_unclean else 1
def set_defaults(kwargs): def set_defaults(kwargs):
if kwargs["config"] is None: if kwargs["config"] is None:
kwargs["config"] = wpt_path('config.ini') kwargs["config"] = wpt_path('config.ini')
updatecommandline.check_args(kwargs) updatecommandline.check_args(kwargs)
def main(): def main():
parser = wptcommandline.create_parser() parser = wptcommandline.create_parser()
kwargs = vars(parser.parse_args()) kwargs = vars(parser.parse_args())

View file

@ -2,14 +2,12 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # 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/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
#!/usr/bin/env python
import argparse
import os import os
import sys import sys
here = os.path.split(__file__)[0] here = os.path.split(__file__)[0]
def wpt_path(*args): def wpt_path(*args):
return os.path.join(here, *args) return os.path.join(here, *args)
@ -17,6 +15,7 @@ def wpt_path(*args):
sys.path.append(wpt_path("harness")) sys.path.append(wpt_path("harness"))
from wptrunner import wptcommandline from wptrunner import wptcommandline
def update_tests(**kwargs): def update_tests(**kwargs):
from wptrunner import update from wptrunner import update
@ -26,11 +25,13 @@ def update_tests(**kwargs):
rv = update.run_update(logger, **kwargs) rv = update.run_update(logger, **kwargs)
return 0 if rv is update.update.exit_clean else 1 return 0 if rv is update.update.exit_clean else 1
def set_defaults(kwargs): def set_defaults(kwargs):
if kwargs["config"] is None: if kwargs["config"] is None:
kwargs["config"] = wpt_path('config_css.ini') kwargs["config"] = wpt_path('config_css.ini')
wptcommandline.set_from_config(kwargs) wptcommandline.set_from_config(kwargs)
def main(): def main():
parser = wptcommandline.create_parser_update() parser = wptcommandline.create_parser_update()
kwargs = vars(parser.parse_args()) kwargs = vars(parser.parse_args())