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

Side by Side Diff: Tools/Scripts/webkitpy/tool/commands/flakytests.py

Issue 312103005: Minor cleanups to flakytests.py (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: address review comments 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) 2011 Google Inc. All rights reserved. 1 # Copyright (c) 2011 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 27 matching lines...) Expand all
38 name = "update-flaky-tests" 38 name = "update-flaky-tests"
39 help_text = "Update FlakyTests file from the flakiness dashboard" 39 help_text = "Update FlakyTests file from the flakiness dashboard"
40 show_in_main_help = True 40 show_in_main_help = True
41 41
42 ALWAYS_CC = [ 42 ALWAYS_CC = [
43 'ojan@chromium.org', 43 'ojan@chromium.org',
44 'dpranke@chromium.org', 44 'dpranke@chromium.org',
45 'eseidel@chromium.org', 45 'eseidel@chromium.org',
46 ] 46 ]
47 47
48 COMMIT_MESSAGE = (
49 'Update FlakyTests to match current flakiness dashboard results\n\n'
50 'Automatically generated using:\n'
51 'webkit-patch update-flaky-tests\n\n'
52 'R=%s\n')
53
54 FLAKY_TEST_CONTENTS = (
55 '# This file is generated by webkit-patch update-flaky-tests from the fl akiness dashboard data.\n'
56 '# Manual changes will be overwritten.\n\n'
57 '%s\n')
58
48 def __init__(self): 59 def __init__(self):
49 options = [ 60 options = [
50 optparse.make_option('--upload', action='store_true', 61 optparse.make_option('--upload', action='store_true',
51 help='upload the changed FlakyTest file for review'), 62 help='upload the changed FlakyTest file for review'),
52 optparse.make_option('--reviewers', action='store', 63 optparse.make_option('--reviewers', action='store',
53 help='comma-separated list of reviewers, defaults to blink garde ners'), 64 help='comma-separated list of reviewers, defaults to blink garde ners'),
54 ] 65 ]
55 AbstractDeclarativeCommand.__init__(self, options=options) 66 AbstractDeclarativeCommand.__init__(self, options=options)
56 # This is sorta silly, but allows for unit testing: 67 # This is sorta silly, but allows for unit testing:
57 self.expectations_factory = BotTestExpectationsFactory 68 self.expectations_factory = BotTestExpectationsFactory
(...skipping 16 matching lines...) Expand all
74 85
75 if options.reviewers: 86 if options.reviewers:
76 # FIXME: Could validate these as emails. sheriff_calendar has some c ode for that. 87 # FIXME: Could validate these as emails. sheriff_calendar has some c ode for that.
77 reviewer_emails = options.reviewers.split(',') 88 reviewer_emails = options.reviewers.split(',')
78 else: 89 else:
79 reviewer_emails = sheriff_calendar.current_gardener_emails() 90 reviewer_emails = sheriff_calendar.current_gardener_emails()
80 if not reviewer_emails: 91 if not reviewer_emails:
81 print "No gardener, and --reviewers not specified, not bothering ." 92 print "No gardener, and --reviewers not specified, not bothering ."
82 return 1 93 return 1
83 94
84 commit_message = """Update FlakyTests to match current flakiness dashboa rd results 95 commit_message = self.COMMIT_MESSAGE % ','.join(reviewer_emails)
85
86 Automatically generated using:
87 webkit-patch update-flaky-tests
88
89 R=%s
90 """ % ','.join(reviewer_emails)
91
92 git_cmd = ['git', 'commit', '-m', commit_message, 96 git_cmd = ['git', 'commit', '-m', commit_message,
93 tool.filesystem.join(tool.scm().checkout_root, flaky_tests_path)] 97 tool.filesystem.join(tool.scm().checkout_root, flaky_tests_path)]
94 tool.executive.run_and_throw_if_fail(git_cmd) 98 tool.executive.run_and_throw_if_fail(git_cmd)
95 99
96 # FIXME: There must be a cleaner way to avoid the editor! 100 git_cmd = ['git', 'cl', 'upload', '--send-mail', '-f',
97 # Silence the editor.
98 os.environ['EDITOR'] = 'true'
99
100 git_cmd = ['git', 'cl', 'upload', '--send-mail',
101 '--cc', ','.join(self.ALWAYS_CC)] 101 '--cc', ','.join(self.ALWAYS_CC)]
102 tool.executive.run_and_throw_if_fail(git_cmd) 102 tool.executive.run_and_throw_if_fail(git_cmd)
103 103
104 def execute(self, options, args, tool): 104 def execute(self, options, args, tool):
105 port = tool.port_factory.get() 105 port = tool.port_factory.get()
106 port_names = tool.port_factory.all_port_names() 106 port_names = tool.port_factory.all_port_names()
107 factory = self.expectations_factory() 107 factory = self.expectations_factory()
108 lines = self._collect_expectation_lines(port_names, factory) 108 lines = self._collect_expectation_lines(port_names, factory)
109 lines.sort(key=lambda line: line.path) 109 lines.sort(key=lambda line: line.path)
110 # Skip any tests which are mentioned in the dashboard but not in our che ckout: 110 # Skip any tests which are mentioned in the dashboard but not in our che ckout:
111 fs = tool.filesystem 111 fs = tool.filesystem
112 lines = filter(lambda line: fs.exists(fs.join(port.layout_tests_dir(), l ine.path)), lines) 112 lines = filter(lambda line: fs.exists(fs.join(port.layout_tests_dir(), l ine.path)), lines)
113 113
114 # Note: This includes all flaky tests from the dashboard, even ones ment ioned 114 # Note: This includes all flaky tests from the dashboard, even ones ment ioned
115 # in existing TestExpectations. We could certainly load existing TestExp ecations 115 # in existing TestExpectations. We could certainly load existing TestExp ecations
116 # and filter accordingly, or update existing TestExpectations instead of FlakyTests. 116 # and filter accordingly, or update existing TestExpectations instead of FlakyTests.
117 flaky_tests_path = fs.join(port.layout_tests_dir(), 'FlakyTests') 117 flaky_tests_path = fs.join(port.layout_tests_dir(), 'FlakyTests')
118 fs.write_text_file(flaky_tests_path, TestExpectations.list_to_string(lin es)) 118 flaky_tests_contents = self.FLAKY_TEST_CONTENTS % TestExpectations.list_ to_string(lines)
119 fs.write_text_file(flaky_tests_path, flaky_tests_contents)
119 print "Updated %s" % flaky_tests_path 120 print "Updated %s" % flaky_tests_path
120 121
121 if options.upload: 122 if options.upload:
122 return self._commit_and_upload(tool, options) 123 return self._commit_and_upload(tool, options)
123 124
OLDNEW
« no previous file with comments | « Tools/Scripts/webkitpy/common/system/executive_mock.py ('k') | Tools/Scripts/webkitpy/tool/commands/flakytests_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698