diff options
Diffstat (limited to 'chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py')
-rw-r--r-- | chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py | 99 |
1 files changed, 65 insertions, 34 deletions
diff --git a/chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py b/chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py index 70998e195b2..70c04f68860 100644 --- a/chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py +++ b/chromium/third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py @@ -46,46 +46,77 @@ EXCEPTIONAL_EXIT_STATUS = 254 _log = logging.getLogger(__name__) -def lint(host, options, logging_stream): +def lint(host, options): + # FIXME: Remove this when we remove the --chromium flag (crbug.com/245504). + if options.platform == 'chromium': + options.platform = None + + ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.all_port_names(options.platform)] + files_linted = set() + lint_failed = False + + for port_to_lint in ports_to_lint: + expectations_dict = port_to_lint.expectations_dict() + + for expectations_file in expectations_dict.keys(): + if expectations_file in files_linted: + continue + + try: + test_expectations.TestExpectations(port_to_lint, + expectations_dict={expectations_file: expectations_dict[expectations_file]}, + is_lint_mode=True) + except test_expectations.ParseError as e: + lint_failed = True + _log.error('') + for warning in e.warnings: + _log.error(warning) + _log.error('') + files_linted.add(expectations_file) + return lint_failed + + +def check_virtual_test_suites(host, options): + port = host.port_factory.get(options=options) + fs = host.filesystem + layout_tests_dir = port.layout_tests_dir() + virtual_suites = port.virtual_test_suites() + + check_failed = False + for suite in virtual_suites: + comps = [layout_tests_dir] + suite.name.split('/') + ['README.txt'] + path_to_readme = fs.join(*comps) + if not fs.exists(path_to_readme): + _log.error('LayoutTests/%s/README.txt is missing (each virtual suite must have one).' % suite.name) + check_failed = True + if check_failed: + _log.error('') + return check_failed + + +def set_up_logging(logging_stream): logger = logging.getLogger() logger.setLevel(logging.INFO) handler = logging.StreamHandler(logging_stream) logger.addHandler(handler) + return (logger, handler) + +def tear_down_logging(logger, handler): + logger.removeHandler(handler) + + +def run_checks(host, options, logging_stream): + logger, handler = set_up_logging(logging_stream) try: - # FIXME: Remove this when we remove the --chromium flag (crbug.com/245504). - if options.platform == 'chromium': - options.platform = None - - ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.all_port_names(options.platform)] - files_linted = set() - lint_failed = False - - for port_to_lint in ports_to_lint: - expectations_dict = port_to_lint.expectations_dict() - - for expectations_file in expectations_dict.keys(): - if expectations_file in files_linted: - continue - - try: - test_expectations.TestExpectations(port_to_lint, - expectations_dict={expectations_file: expectations_dict[expectations_file]}, - is_lint_mode=True) - except test_expectations.ParseError as e: - lint_failed = True - _log.error('') - for warning in e.warnings: - _log.error(warning) - _log.error('') - files_linted.add(expectations_file) - - if lint_failed: + lint_failed = lint(host, options) + check_failed = check_virtual_test_suites(host, options) + if lint_failed or check_failed: _log.error('Lint failed.') - return -1 - - _log.info('Lint succeeded.') - return 0 + return 1 + else: + _log.info('Lint succeeded.') + return 0 finally: logger.removeHandler(handler) @@ -104,7 +135,7 @@ def main(argv, _, stderr): host = Host() try: - exit_status = lint(host, options, stderr) + exit_status = run_checks(host, options, stderr) except KeyboardInterrupt: exit_status = INTERRUPTED_EXIT_STATUS except Exception as e: |