Chromium Code Reviews| Index: build/android/buildbot/bb_device_steps.py |
| diff --git a/build/android/buildbot/bb_device_steps.py b/build/android/buildbot/bb_device_steps.py |
| index 260ec76086b7bbbcc87a69b220167861e72fc8ad..402a7f26e7a5621dedef40ed8db1ce1b8cb8f0e4 100755 |
| --- a/build/android/buildbot/bb_device_steps.py |
| +++ b/build/android/buildbot/bb_device_steps.py |
| @@ -5,8 +5,10 @@ |
| import collections |
| import glob |
| +import hashlib |
| import multiprocessing |
| import os |
| +import random |
| import shutil |
| import sys |
| @@ -26,6 +28,7 @@ import errors |
| CHROME_SRC = constants.DIR_SOURCE_ROOT |
| LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') |
| +REVISION_FILENAME = 'FULL_BUILD_REVISION' |
| # Describes an instrumation test suite: |
| # test: Name of test we're running. |
| @@ -165,6 +168,8 @@ def RunInstrumentationSuite(options, test, flunk_on_failure=True, |
| if options.flakiness_server: |
| args.append('--flakiness-dashboard-server=%s' % |
| options.flakiness_server) |
| + if options.coverage_bucket: |
| + args.append('--coverage-dir=%s' % options.coverage_dir) |
| if test.host_driven_root: |
| args.append('--host-driven-root=%s' % test.host_driven_root) |
| if test.annotation: |
| @@ -294,6 +299,31 @@ def GetTestStepCmds(): |
| ] |
| +def UploadCoverageData(options, path, coverage_type): |
|
frankf
2013/08/21 01:13:45
Add docstring
gkanwar1
2013/08/21 01:29:13
Done.
|
| + revision = options.build_properties.get('got_revision', 'testing') |
| + bot_id = options.build_properties.get('buildername', 'testing') |
| + |
| + randhash = hashlib.sha1(str(random.random())).hexdigest() |
| + |
| + RunCmd([bb_utils.GSUTIL_PATH, 'cp', '-R', path, 'gs://%s/%s/%s/%s/%s' % |
| + (options.coverage_bucket, coverage_type, bot_id, revision, randhash)]) |
|
frankf
2013/08/21 01:13:45
DRY, create a var for gs path
gkanwar1
2013/08/21 01:29:13
Done.
|
| + bb_annotations.PrintLink( |
| + 'Coverage report', |
| + 'https://storage.googleapis.com/%s/%s/%s/%s/%s/index.html' |
| + % (options.coverage_bucket, coverage_type, bot_id, revision, randhash)) |
| + |
| + |
| +def GenerateJavaCoverageReport(options): |
| + bb_annotations.PrintNamedStep('java_coverage_report') |
| + |
| + coverage_html = os.path.join(options.coverage_dir, 'coverage_html') |
| + RunCmd(['build/android/generate_emma_html.py', |
| + '--coverage-dir', options.coverage_dir, |
| + '--metadata-dir', os.path.join(CHROME_SRC, 'out', options.target), |
| + '--output', os.path.join(coverage_html, 'index.html')]) |
| + UploadCoverageData(options, coverage_html, 'java') |
| + |
| + |
| def LogcatDump(options): |
| # Print logcat, kill logcat monitor |
| bb_annotations.PrintNamedStep('logcat_dump') |
| @@ -329,6 +359,9 @@ def MainTestWrapper(options): |
| if options.test_filter: |
| bb_utils.RunSteps(options.test_filter, GetTestStepCmds(), options) |
| + if options.coverage_bucket: |
| + GenerateJavaCoverageReport(options) |
| + |
| if options.experimental: |
| RunTestSuites(options, gtest_config.EXPERIMENTAL_TEST_SUITES) |
| @@ -354,6 +387,9 @@ def GetDeviceStepsOptParser(): |
| help='Install an apk by name') |
| parser.add_option('--reboot', action='store_true', |
| help='Reboot devices before running tests') |
| + parser.add_option('--coverage-bucket', |
| + help=('Bucket name to store coverage results. Coverage is ' |
| + 'only run if this is set.')) |
| parser.add_option( |
| '--flakiness-server', |
| help='The flakiness dashboard server to which the results should be ' |
| @@ -380,6 +416,9 @@ def main(argv): |
| return sys.exit('Unknown tests %s' % list(unknown_tests)) |
| setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |
| + if options.coverage_bucket: |
| + setattr(options, 'coverage_dir', |
| + os.path.join(CHROME_SRC, 'out', options.target, 'coverage')) |
| MainTestWrapper(options) |