Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(777)

Unified Diff: build/android/buildbot/bb_device_steps.py

Issue 20210002: [Android] Sets up a coverage system for java using EMMA (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Break apart native and java coverage flags for gyp Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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 32438ae8fc47479a96b2d6d96e35ae133528cfc6..e939110393551f51b76f8caf8d97a8b1a297e973 100755
--- a/build/android/buildbot/bb_device_steps.py
+++ b/build/android/buildbot/bb_device_steps.py
@@ -24,8 +24,11 @@ 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')
+COVERAGE_DIR = os.path.join(CHROME_SRC, 'out', 'coverage')
frankf 2013/08/13 23:33:39 Move this to constants.py
gkanwar1 2013/08/15 19:49:20 Done.
+REVISION_FILENAME = 'FULL_BUILD_REVISION'
# Describes an instrumation test suite:
# test: Name of test we're running.
@@ -37,26 +40,28 @@ 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=False,
+ 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',
+ coverage=True),
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),
I('AndroidWebView',
'AndroidWebView.apk',
'org.chromium.android_webview.shell',
@@ -165,6 +170,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' % COVERAGE_DIR)
if test.host_driven_root:
args.append('--python_test_root=%s' % test.host_driven_root)
if test.annotation:
@@ -272,6 +279,32 @@ def RunInstrumentationTests(options):
for test in INSTRUMENTATION_TESTS.itervalues():
RunInstrumentationSuite(options, test)
+ if options.coverage_bucket:
+ shutil.rmtree(COVERAGE_DIR, ignore_errors=True)
+ os.mkdir(COVERAGE_DIR)
+ RunCmd(['build/android/generate_emma_html.py',
+ '--coverage-dir', COVERAGE_DIR,
+ '--metadata-dir', os.path.join('out', options.target),
frankf 2013/08/13 23:33:39 How does this work? Did yo forget constants.DIR_SO
gkanwar1 2013/08/15 19:49:20 It's relative to the python running directory, whi
+ '--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'
+
+ RunCmd([os.path.join(bb_utils.BB_BUILD_DIR, 'scripts',
+ 'slave', 'gsutil_cp_dir.py'),
+ os.path.join(COVERAGE_DIR), 'gs://%s/%s' %
+ (options.coverage_bucket, revision)])
frankf 2013/08/13 23:33:39 As it stands, you're going to upload from all fyi
gkanwar1 2013/08/15 19:49:20 Yep, good point. Changing url to gs://<bucket>/<bo
+ 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'])
@@ -353,6 +386,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 '

Powered by Google App Engine
This is Rietveld 408576698