[Android] Make UploadCoverageData generic to upload any html artifact.

BUG=278634
R=cmp@chromium.org

Review URL: https://codereview.chromium.org/23591055

git-svn-id: http://src.chromium.org/svn/trunk/src/build@223643 4ff67af0-8c30-449e-8e8b-ad334ec8d88c
This commit is contained in:
frankf@chromium.org 2013-09-17 18:32:12 +00:00
Родитель 68fbba6e0a
Коммит 181fedbfd3
1 изменённых файлов: 18 добавлений и 18 удалений

Просмотреть файл

@ -30,6 +30,7 @@ import errors
SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave')
LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat') LOGCAT_DIR = os.path.join(bb_utils.CHROME_OUT_DIR, 'logcat')
GS_URL = 'https://storage.googleapis.com'
# Describes an instrumation test suite: # Describes an instrumation test suite:
# test: Name of test we're running. # test: Name of test we're running.
@ -335,31 +336,28 @@ def GetTestStepCmds():
] ]
def UploadCoverageData(options, path, coverage_type): def UploadHTML(options, gs_base_dir, dir_to_upload, link_text,
"""Uploads directory at |path| to Google Storage. link_rel_path='index.html', gs_url=GS_URL):
"""Uploads directory at |dir_to_upload| to Google Storage and output a link.
The directory at path should ostensibly contain HTML coverage data.
Args: Args:
options: Command line options. options: Command line options.
path: Path to the directory to be uploaded. gs_base_dir: The Google Storage base directory (e.g.
coverage_type: String used as the first component of the url. 'chromium-code-coverage/java')
dir_to_upload: Absolute path to the directory to be uploaded.
Returns: link_text: Link text to be displayed on the step.
None. link_rel_path: Link path relative to |dir_to_upload|.
gs_url: Google storage URL.
""" """
revision = options.build_properties.get('got_revision') revision = options.build_properties.get('got_revision')
if not revision: if not revision:
revision = options.build_properties.get('revision', 'testing') revision = options.build_properties.get('revision', 'testing')
bot_id = options.build_properties.get('buildername', 'testing') bot_id = options.build_properties.get('buildername', 'testing')
randhash = hashlib.sha1(str(random.random())).hexdigest() randhash = hashlib.sha1(str(random.random())).hexdigest()
gs_path = '%s/%s/%s/%s/%s' % (options.coverage_bucket, coverage_type, gs_path = '%s/%s/%s/%s' % (gs_base_dir, bot_id, revision, randhash)
bot_id, revision, randhash) RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', dir_to_upload, 'gs://%s' % gs_path])
bb_annotations.PrintLink(link_text,
RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', path, 'gs://%s' % gs_path]) '%s/%s/%s' % (gs_url, gs_path, link_rel_path))
bb_annotations.PrintLink(
'Coverage report',
'https://storage.googleapis.com/%s/index.html' % gs_path)
def GenerateJavaCoverageReport(options): def GenerateJavaCoverageReport(options):
@ -372,7 +370,7 @@ def GenerateJavaCoverageReport(options):
'--metadata-dir', os.path.join(CHROME_OUT_DIR, options.target), '--metadata-dir', os.path.join(CHROME_OUT_DIR, options.target),
'--cleanup', '--cleanup',
'--output', os.path.join(coverage_html, 'index.html')]) '--output', os.path.join(coverage_html, 'index.html')])
UploadCoverageData(options, coverage_html, 'java') return coverage_html
def LogcatDump(options): def LogcatDump(options):
@ -412,7 +410,9 @@ def MainTestWrapper(options):
bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options)
if options.coverage_bucket: if options.coverage_bucket:
GenerateJavaCoverageReport(options) coverage_html = GenerateJavaCoverageReport(options)
UploadHTML(options, '%s/java' % options.coverage_bucket, coverage_html,
'Coverage Report')
if options.experimental: if options.experimental:
RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES)