Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(189)

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/lint_test_expectations.py

Issue 267803007: Add checks for READMEs for each virtual test suite. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: merge to r175714 Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright (C) 2012 Google Inc. All rights reserved. 1 # Copyright (C) 2012 Google Inc. All rights reserved.
2 # 2 #
3 # Redistribution and use in source and binary forms, with or without 3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are 4 # modification, are permitted provided that the following conditions are
5 # met: 5 # met:
6 # 6 #
7 # * Redistributions of source code must retain the above copyright 7 # * Redistributions of source code must retain the above copyright
8 # notice, this list of conditions and the following disclaimer. 8 # notice, this list of conditions and the following disclaimer.
9 # * Redistributions in binary form must reproduce the above 9 # * Redistributions in binary form must reproduce the above
10 # copyright notice, this list of conditions and the following disclaimer 10 # copyright notice, this list of conditions and the following disclaimer
(...skipping 28 matching lines...) Expand all
39 # This mirrors what the shell normally does. 39 # This mirrors what the shell normally does.
40 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128 40 INTERRUPTED_EXIT_STATUS = signal.SIGINT + 128
41 41
42 # This is a randomly chosen exit code that can be tested against to 42 # This is a randomly chosen exit code that can be tested against to
43 # indicate that an unexpected exception occurred. 43 # indicate that an unexpected exception occurred.
44 EXCEPTIONAL_EXIT_STATUS = 254 44 EXCEPTIONAL_EXIT_STATUS = 254
45 45
46 _log = logging.getLogger(__name__) 46 _log = logging.getLogger(__name__)
47 47
48 48
49 def lint(host, options, logging_stream): 49 def lint(host, options):
50 # FIXME: Remove this when we remove the --chromium flag (crbug.com/245504).
51 if options.platform == 'chromium':
52 options.platform = None
53
54 ports_to_lint = [host.port_factory.get(name) for name in host.port_factory.a ll_port_names(options.platform)]
55 files_linted = set()
56 lint_failed = False
57
58 for port_to_lint in ports_to_lint:
59 expectations_dict = port_to_lint.expectations_dict()
60
61 for expectations_file in expectations_dict.keys():
62 if expectations_file in files_linted:
63 continue
64
65 try:
66 test_expectations.TestExpectations(port_to_lint,
67 expectations_dict={expectations_file: expectations_dict[expe ctations_file]},
68 is_lint_mode=True)
69 except test_expectations.ParseError as e:
70 lint_failed = True
71 _log.error('')
72 for warning in e.warnings:
73 _log.error(warning)
74 _log.error('')
75 files_linted.add(expectations_file)
76 return lint_failed
77
78
79 def check_virtual_test_suites(host, options):
80 port = host.port_factory.get(options=options)
81 fs = host.filesystem
82 layout_tests_dir = port.layout_tests_dir()
83 virtual_suites = port.virtual_test_suites()
84
85 check_failed = False
86 for suite in virtual_suites:
87 comps = [layout_tests_dir] + suite.name.split('/') + ['README.txt']
88 path_to_readme = fs.join(*comps)
89 if not fs.exists(path_to_readme):
90 _log.error('LayoutTests/%s/README.txt is missing (each virtual suite must have one).' % suite.name)
91 check_failed = True
92 if check_failed:
93 _log.error('')
94 return check_failed
95
96
97 def set_up_logging(logging_stream):
50 logger = logging.getLogger() 98 logger = logging.getLogger()
51 logger.setLevel(logging.INFO) 99 logger.setLevel(logging.INFO)
52 handler = logging.StreamHandler(logging_stream) 100 handler = logging.StreamHandler(logging_stream)
53 logger.addHandler(handler) 101 logger.addHandler(handler)
102 return (logger, handler)
54 103
104
105 def tear_down_logging(logger, handler):
106 logger.removeHandler(handler)
107
108
109 def run_checks(host, options, logging_stream):
110 logger, handler = set_up_logging(logging_stream)
55 try: 111 try:
56 # FIXME: Remove this when we remove the --chromium flag (crbug.com/24550 4). 112 lint_failed = lint(host, options)
57 if options.platform == 'chromium': 113 check_failed = check_virtual_test_suites(host, options)
58 options.platform = None 114 if lint_failed or check_failed:
59
60 ports_to_lint = [host.port_factory.get(name) for name in host.port_facto ry.all_port_names(options.platform)]
61 files_linted = set()
62 lint_failed = False
63
64 for port_to_lint in ports_to_lint:
65 expectations_dict = port_to_lint.expectations_dict()
66
67 for expectations_file in expectations_dict.keys():
68 if expectations_file in files_linted:
69 continue
70
71 try:
72 test_expectations.TestExpectations(port_to_lint,
73 expectations_dict={expectations_file: expectations_dict[ expectations_file]},
74 is_lint_mode=True)
75 except test_expectations.ParseError as e:
76 lint_failed = True
77 _log.error('')
78 for warning in e.warnings:
79 _log.error(warning)
80 _log.error('')
81 files_linted.add(expectations_file)
82
83 if lint_failed:
84 _log.error('Lint failed.') 115 _log.error('Lint failed.')
85 return -1 116 return 1
86 117 else:
87 _log.info('Lint succeeded.') 118 _log.info('Lint succeeded.')
88 return 0 119 return 0
89 finally: 120 finally:
90 logger.removeHandler(handler) 121 logger.removeHandler(handler)
91 122
92 123
93 def main(argv, _, stderr): 124 def main(argv, _, stderr):
94 parser = optparse.OptionParser(option_list=platform_options(use_globs=True)) 125 parser = optparse.OptionParser(option_list=platform_options(use_globs=True))
95 options, _ = parser.parse_args(argv) 126 options, _ = parser.parse_args(argv)
96 127
97 if options.platform and 'test' in options.platform: 128 if options.platform and 'test' in options.platform:
98 # It's a bit lame to import mocks into real code, but this allows the us er 129 # It's a bit lame to import mocks into real code, but this allows the us er
99 # to run tests against the test platform interactively, which is useful for 130 # to run tests against the test platform interactively, which is useful for
100 # debugging test failures. 131 # debugging test failures.
101 from webkitpy.common.host_mock import MockHost 132 from webkitpy.common.host_mock import MockHost
102 host = MockHost() 133 host = MockHost()
103 else: 134 else:
104 host = Host() 135 host = Host()
105 136
106 try: 137 try:
107 exit_status = lint(host, options, stderr) 138 exit_status = run_checks(host, options, stderr)
108 except KeyboardInterrupt: 139 except KeyboardInterrupt:
109 exit_status = INTERRUPTED_EXIT_STATUS 140 exit_status = INTERRUPTED_EXIT_STATUS
110 except Exception as e: 141 except Exception as e:
111 print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e)) 142 print >> stderr, '\n%s raised: %s' % (e.__class__.__name__, str(e))
112 traceback.print_exc(file=stderr) 143 traceback.print_exc(file=stderr)
113 exit_status = EXCEPTIONAL_EXIT_STATUS 144 exit_status = EXCEPTIONAL_EXIT_STATUS
114 145
115 return exit_status 146 return exit_status
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698