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 f020281bb7d751434151ee4f9f9d4c5ddfd4affc..896b8c10459f2bef5d3e8900f9338a3753f2b8ed 100755 |
| --- a/build/android/buildbot/bb_device_steps.py |
| +++ b/build/android/buildbot/bb_device_steps.py |
| @@ -24,8 +24,10 @@ sys.path.append(os.path.join( |
| import errors |
| +SLAVE_SCRIPTS_DIR = os.path.join(bb_utils.BB_BUILD_DIR, 'scripts', 'slave') |
| CHROME_SRC = constants.DIR_SOURCE_ROOT |
| LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') |
| +REVISION_FILENAME = 'FULL_BUILD_REVISION' |
|
bulach
2013/08/20 17:42:34
what's this?
it'd be nice to reuse the one we have
|
| # Describes an instrumation test suite: |
| # test: Name of test we're running. |
| @@ -37,31 +39,35 @@ LOGCAT_DIR = os.path.join(CHROME_SRC, 'out', 'logcat') |
| # annotation: Annotation of the tests to include. |
| # exclude_annotation: The annotation of the tests to exclude. |
| I_TEST = collections.namedtuple('InstrumentationTest', [ |
| - 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'host_driven_root', |
| - 'annotation', 'exclude_annotation', 'extra_flags']) |
| + 'name', 'apk', 'apk_package', 'test_apk', 'test_data', 'coverage', |
| + 'host_driven_root', 'annotation', 'exclude_annotation', 'extra_flags']) |
| -def I(name, apk, apk_package, test_apk, test_data, host_driven_root=None, |
| - annotation=None, exclude_annotation=None, extra_flags=None): |
| - return I_TEST(name, apk, apk_package, test_apk, test_data, host_driven_root, |
| - annotation, exclude_annotation, extra_flags) |
| +def I(name, apk, apk_package, test_apk, test_data, coverage=True, |
| + host_driven_root=None, annotation=None, exclude_annotation=None, |
| + extra_flags=None): |
| + return I_TEST(name, apk, apk_package, test_apk, test_data, coverage, |
| + host_driven_root, annotation, exclude_annotation, extra_flags) |
| INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ |
| I('ContentShell', |
| 'ContentShell.apk', |
| 'org.chromium.content_shell_apk', |
| 'ContentShellTest', |
| - 'content:content/test/data/android/device_files'), |
| + 'content:content/test/data/android/device_files', |
| + annotation='SmallTest'), |
|
bulach
2013/08/20 17:42:34
why only SmallTest?
|
| I('ChromiumTestShell', |
| 'ChromiumTestShell.apk', |
| 'org.chromium.chrome.testshell', |
| 'ChromiumTestShellTest', |
| 'chrome:chrome/test/data/android/device_files', |
| - constants.CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR), |
| + host_driven_root=constants.CHROMIUM_TEST_SHELL_HOST_DRIVEN_DIR, |
|
bulach
2013/08/20 17:42:34
unrelated?
|
| + annotation='SmallTest'), |
| I('AndroidWebView', |
| 'AndroidWebView.apk', |
| 'org.chromium.android_webview.shell', |
| 'AndroidWebViewTest', |
| - 'webview:android_webview/test/data/device_files'), |
| + 'webview:android_webview/test/data/device_files', |
| + annotation='SmallTest'), |
| ]) |
| VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout', |
| @@ -165,6 +171,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 and test.coverage: |
| + args.append('--coverage-dir=%s' % constants.GetCoverageDir(options.target)) |
| if test.host_driven_root: |
| args.append('--host-driven-root=%s' % test.host_driven_root) |
| if test.annotation: |
| @@ -271,9 +279,48 @@ def RunUnitTests(options): |
| def RunInstrumentationTests(options): |
| + coverage_dir = constants.GetCoverageDir(options.target) |
| + if options.coverage_bucket: |
| + shutil.rmtree(coverage_dir, ignore_errors=True) |
| + os.mkdir(coverage_dir) |
| + |
| for test in INSTRUMENTATION_TESTS.itervalues(): |
| RunInstrumentationSuite(options, test) |
| + if options.coverage_bucket: |
| + print 'generate_emma_html perms: %s' % RunCmd( |
| + ['ls', '-l', 'build/android/generate_emma_html.py']) |
|
bulach
2013/08/20 17:42:34
not needed?
|
| + RunCmd(['build/android/generate_emma_html.py', |
| + '--coverage-dir', coverage_dir, |
| + '--metadata-dir', os.path.join(constants.DIR_SOURCE_ROOT, |
| + 'out', options.target), |
| + '--output', os.path.join(coverage_dir, 'coverage.html')]) |
| + |
| + revision_file = os.path.join(CHROME_SRC, 'out', options.target, |
| + REVISION_FILENAME) |
| + # If the revision file doesn't exist, we're just testing the bot |
| + if os.path.exists(revision_file): |
| + with open(revision_file) as f: |
| + revision = f.read() |
| + else: |
| + revision = 'testing' |
| + bot_id = os.environ.get('BUILDBOT_ID') |
| + if not bot_id: |
| + print 'BUILDBOT_ID requried in the environment to upload coverage data.' |
| + return |
| + |
| + boto_config = os.path.join(bb_utils.BB_BUILD_DIR, 'site_config', '.boto') |
| + os.environ['AWS_CREDENTIAL_FILE'] = boto_config |
| + os.environ['BOTO_CONFIG'] = boto_config |
| + RunCmd([os.path.join(bb_utils.BB_BUILD_DIR, 'third_party', |
| + 'gsutil', 'gsutil'), 'cp', '-R', |
| + coverage_dir, 'gs://%s/%s/%s' % |
| + (options.coverage_bucket, bot_id, revision)]) |
| + bb_annotations.PrintLink( |
| + 'Coverage report', |
| + 'https://storage.googleapis.com/%s/%s/coverage.html' |
| + % (options.coverage_bucket, revision)) |
| + |
| def RunWebkitTests(options): |
| RunTestSuites(options, ['webkit_unit_tests']) |
| @@ -355,6 +402,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 ' |