OLD | NEW |
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 """Uploads the results to the flakiness dashboard server.""" | 5 """Uploads the results to the flakiness dashboard server.""" |
6 | 6 |
7 import logging | 7 import logging |
8 import os | 8 import os |
9 import shutil | 9 import shutil |
10 import subprocess | 10 import subprocess |
(...skipping 12 matching lines...) Expand all Loading... |
23 sys.path.append( | 23 sys.path.append( |
24 os.path.abspath(os.path.join(os.path.dirname(__file__), | 24 os.path.abspath(os.path.join(os.path.dirname(__file__), |
25 os.pardir, os.pardir, os.pardir, os.pardir, | 25 os.pardir, os.pardir, os.pardir, os.pardir, |
26 os.pardir, os.pardir, os.pardir, | 26 os.pardir, os.pardir, os.pardir, |
27 'Tools', 'Scripts'))) | 27 'Tools', 'Scripts'))) |
28 | 28 |
29 from webkitpy.common.system import executive, filesystem | 29 from webkitpy.common.system import executive, filesystem |
30 from webkitpy.layout_tests.layout_package import json_results_generator | 30 from webkitpy.layout_tests.layout_package import json_results_generator |
31 | 31 |
32 #TODO(craigdh): pylib/utils/ should not depend on pylib/. | 32 #TODO(craigdh): pylib/utils/ should not depend on pylib/. |
| 33 from pylib import cmd_helper |
33 from pylib import constants | 34 from pylib import constants |
34 | 35 |
35 | 36 |
36 # The JSONResultsGenerator gets the filesystem.join operation from the Port | 37 # The JSONResultsGenerator gets the filesystem.join operation from the Port |
37 # object. Creating a Port object requires specifying information that only | 38 # object. Creating a Port object requires specifying information that only |
38 # makes sense for running WebKit layout tests, so we provide a dummy object | 39 # makes sense for running WebKit layout tests, so we provide a dummy object |
39 # that contains the fields required by the generator. | 40 # that contains the fields required by the generator. |
40 class PortDummy(object): | 41 class PortDummy(object): |
41 def __init__(self): | 42 def __init__(self): |
42 self._executive = executive.Executive() | 43 self._executive = executive.Executive() |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 return False | 91 return False |
91 return _is_git_directory(parent) | 92 return _is_git_directory(parent) |
92 | 93 |
93 def _get_git_revision(in_directory): | 94 def _get_git_revision(in_directory): |
94 """Returns the git hash tag for the given directory. | 95 """Returns the git hash tag for the given directory. |
95 | 96 |
96 Args: | 97 Args: |
97 in_directory: The directory where git is to be run. | 98 in_directory: The directory where git is to be run. |
98 """ | 99 """ |
99 command_line = ['git', 'log', '-1', '--pretty=format:%H'] | 100 command_line = ['git', 'log', '-1', '--pretty=format:%H'] |
100 output = subprocess.Popen(command_line, | 101 output = cmd_helper.GetCmdOutput(command_line, cwd=in_directory) |
101 cwd=in_directory, | |
102 stdout=subprocess.PIPE).communicate()[0] | |
103 return output[0:40] | 102 return output[0:40] |
104 | 103 |
105 in_directory = os.path.join(constants.CHROME_DIR, in_directory) | 104 in_directory = os.path.join(constants.CHROME_DIR, in_directory) |
106 | 105 |
107 if not os.path.exists(os.path.join(in_directory, '.svn')): | 106 if not os.path.exists(os.path.join(in_directory, '.svn')): |
108 if _is_git_directory(in_directory): | 107 if _is_git_directory(in_directory): |
109 return _get_git_revision(in_directory) | 108 return _get_git_revision(in_directory) |
110 else: | 109 else: |
111 return '' | 110 return '' |
112 | 111 |
113 # Note: Not thread safe: http://bugs.python.org/issue2320 | 112 output = cmd_helper.GetCmdOutput(['svn', 'info', '--xml'], cwd=in_directory) |
114 output = subprocess.Popen(['svn', 'info', '--xml'], | |
115 cwd=in_directory, | |
116 stdout=subprocess.PIPE).communicate()[0] | |
117 try: | 113 try: |
118 dom = xml.dom.minidom.parseString(output) | 114 dom = xml.dom.minidom.parseString(output) |
119 return dom.getElementsByTagName('entry')[0].getAttribute('revision') | 115 return dom.getElementsByTagName('entry')[0].getAttribute('revision') |
120 except xml.parsers.expat.ExpatError: | 116 except xml.parsers.expat.ExpatError: |
121 return '' | 117 return '' |
122 return '' | 118 return '' |
123 | 119 |
124 | 120 |
125 class ResultsUploader(object): | 121 class ResultsUploader(object): |
126 """Handles uploading buildbot tests results to the flakiness dashboard.""" | 122 """Handles uploading buildbot tests results to the flakiness dashboard.""" |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 """Reports test results to the flakiness dashboard for Chrome for Android. | 206 """Reports test results to the flakiness dashboard for Chrome for Android. |
211 | 207 |
212 Args: | 208 Args: |
213 results: test results. | 209 results: test results. |
214 flakiness_dashboard_server: the server to upload the results to. | 210 flakiness_dashboard_server: the server to upload the results to. |
215 test_type: the type of the tests (as displayed by the flakiness dashboard). | 211 test_type: the type of the tests (as displayed by the flakiness dashboard). |
216 """ | 212 """ |
217 uploader = ResultsUploader(test_type) | 213 uploader = ResultsUploader(test_type) |
218 uploader.AddResults(results) | 214 uploader.AddResults(results) |
219 uploader.Upload(flakiness_dashboard_server) | 215 uploader.Upload(flakiness_dashboard_server) |
OLD | NEW |