| 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 # pylint: disable=E1002,R0201 | 6 # pylint: disable=E1002,R0201 | 
| 7 | 7 | 
| 8 import logging | 8 import logging | 
| 9 import os | 9 import os | 
| 10 import shutil | 10 import shutil | 
| 11 import tempfile | 11 import tempfile | 
| 12 import xml | 12 import xml | 
| 13 | 13 | 
| 14 | 14 | 
| 15 from devil.utils import cmd_helper | 15 from devil.utils import cmd_helper | 
| 16 from pylib import constants | 16 from pylib.constants import host_paths | 
| 17 from pylib.results.flakiness_dashboard import json_results_generator | 17 from pylib.results.flakiness_dashboard import json_results_generator | 
| 18 from pylib.utils import repo_utils | 18 from pylib.utils import repo_utils | 
| 19 | 19 | 
| 20 | 20 | 
| 21 | 21 | 
| 22 class JSONResultsGenerator(json_results_generator.JSONResultsGeneratorBase): | 22 class JSONResultsGenerator(json_results_generator.JSONResultsGeneratorBase): | 
| 23   """Writes test results to a JSON file and handles uploading that file to | 23   """Writes test results to a JSON file and handles uploading that file to | 
| 24   the test results server. | 24   the test results server. | 
| 25   """ | 25   """ | 
| 26   def __init__(self, builder_name, build_name, build_number, tmp_folder, | 26   def __init__(self, builder_name, build_name, build_number, tmp_folder, | 
| (...skipping 27 matching lines...) Expand all  Loading... | 
| 54     """ | 54     """ | 
| 55     def _is_git_directory(in_directory): | 55     def _is_git_directory(in_directory): | 
| 56       """Returns true if the given directory is in a git repository. | 56       """Returns true if the given directory is in a git repository. | 
| 57 | 57 | 
| 58       Args: | 58       Args: | 
| 59         in_directory: The directory path to be tested. | 59         in_directory: The directory path to be tested. | 
| 60       """ | 60       """ | 
| 61       if os.path.exists(os.path.join(in_directory, '.git')): | 61       if os.path.exists(os.path.join(in_directory, '.git')): | 
| 62         return True | 62         return True | 
| 63       parent = os.path.dirname(in_directory) | 63       parent = os.path.dirname(in_directory) | 
| 64       if parent == constants.DIR_SOURCE_ROOT or parent == in_directory: | 64       if parent == host_paths.DIR_SOURCE_ROOT or parent == in_directory: | 
| 65         return False | 65         return False | 
| 66       return _is_git_directory(parent) | 66       return _is_git_directory(parent) | 
| 67 | 67 | 
| 68     in_directory = os.path.join(constants.DIR_SOURCE_ROOT, in_directory) | 68     in_directory = os.path.join(host_paths.DIR_SOURCE_ROOT, in_directory) | 
| 69 | 69 | 
| 70     if not os.path.exists(os.path.join(in_directory, '.svn')): | 70     if not os.path.exists(os.path.join(in_directory, '.svn')): | 
| 71       if _is_git_directory(in_directory): | 71       if _is_git_directory(in_directory): | 
| 72         return repo_utils.GetGitHeadSHA1(in_directory) | 72         return repo_utils.GetGitHeadSHA1(in_directory) | 
| 73       else: | 73       else: | 
| 74         return '' | 74         return '' | 
| 75 | 75 | 
| 76     output = cmd_helper.GetCmdOutput(['svn', 'info', '--xml'], cwd=in_directory) | 76     output = cmd_helper.GetCmdOutput(['svn', 'info', '--xml'], cwd=in_directory) | 
| 77     try: | 77     try: | 
| 78       dom = xml.dom.minidom.parseString(output) | 78       dom = xml.dom.minidom.parseString(output) | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 92     if not self._build_number or not self._builder_name: | 92     if not self._build_number or not self._builder_name: | 
| 93       raise Exception('You should not be uploading tests results to the server' | 93       raise Exception('You should not be uploading tests results to the server' | 
| 94                       'from your local machine.') | 94                       'from your local machine.') | 
| 95 | 95 | 
| 96     upstream = (tests_type != 'Chromium_Android_Instrumentation') | 96     upstream = (tests_type != 'Chromium_Android_Instrumentation') | 
| 97     if upstream: | 97     if upstream: | 
| 98       # TODO(frankf): Use factory properties (see buildbot/bb_device_steps.py) | 98       # TODO(frankf): Use factory properties (see buildbot/bb_device_steps.py) | 
| 99       # This requires passing the actual master name (e.g. 'ChromiumFYI' not | 99       # This requires passing the actual master name (e.g. 'ChromiumFYI' not | 
| 100       # 'chromium.fyi'). | 100       # 'chromium.fyi'). | 
| 101       from slave import slave_utils # pylint: disable=F0401 | 101       from slave import slave_utils # pylint: disable=F0401 | 
| 102       self._build_name = slave_utils.SlaveBuildName(constants.DIR_SOURCE_ROOT) | 102       self._build_name = slave_utils.SlaveBuildName(host_paths.DIR_SOURCE_ROOT) | 
| 103       self._master_name = slave_utils.GetActiveMaster() | 103       self._master_name = slave_utils.GetActiveMaster() | 
| 104     else: | 104     else: | 
| 105       self._build_name = 'chromium-android' | 105       self._build_name = 'chromium-android' | 
| 106       buildbot_branch = os.environ.get('BUILDBOT_BRANCH') | 106       buildbot_branch = os.environ.get('BUILDBOT_BRANCH') | 
| 107       if not buildbot_branch: | 107       if not buildbot_branch: | 
| 108         buildbot_branch = 'master' | 108         buildbot_branch = 'master' | 
| 109       else: | 109       else: | 
| 110         # Ensure there's no leading "origin/" | 110         # Ensure there's no leading "origin/" | 
| 111         buildbot_branch = buildbot_branch[buildbot_branch.find('/') + 1:] | 111         buildbot_branch = buildbot_branch[buildbot_branch.find('/') + 1:] | 
| 112       self._master_name = '%s-%s' % (self._build_name, buildbot_branch) | 112       self._master_name = '%s-%s' % (self._build_name, buildbot_branch) | 
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 172   """Reports test results to the flakiness dashboard for Chrome for Android. | 172   """Reports test results to the flakiness dashboard for Chrome for Android. | 
| 173 | 173 | 
| 174   Args: | 174   Args: | 
| 175     results: test results. | 175     results: test results. | 
| 176     flakiness_dashboard_server: the server to upload the results to. | 176     flakiness_dashboard_server: the server to upload the results to. | 
| 177     test_type: the type of the tests (as displayed by the flakiness dashboard). | 177     test_type: the type of the tests (as displayed by the flakiness dashboard). | 
| 178   """ | 178   """ | 
| 179   uploader = ResultsUploader(test_type) | 179   uploader = ResultsUploader(test_type) | 
| 180   uploader.AddResults(results) | 180   uploader.AddResults(results) | 
| 181   uploader.Upload(flakiness_dashboard_server) | 181   uploader.Upload(flakiness_dashboard_server) | 
| OLD | NEW | 
|---|