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 f9e2883b18900d4a53a7680cc2f43ba061a61de7..8e55dfe385cdf9cf22164f6480a397d054a772a9 100755 |
--- a/build/android/buildbot/bb_device_steps.py |
+++ b/build/android/buildbot/bb_device_steps.py |
@@ -5,15 +5,18 @@ |
import collections |
import glob |
-import json |
import multiprocessing |
import optparse |
import os |
-import pipes |
import shutil |
-import subprocess |
import sys |
Isaac (away)
2013/05/29 20:28:07
change to
import bb_utils
Siva Chandra
2013/06/04 00:34:03
Done.
|
+from bb_utils import ConvertJson |
+from bb_utils import OptParserError |
+from bb_utils import RunCmd |
+from bb_utils import SpawnCmd |
+from bb_utils import TESTING |
+ |
sys.path.append(os.path.join(os.path.dirname(__file__), '..')) |
from pylib import android_commands |
from pylib import buildbot_report |
@@ -25,8 +28,6 @@ sys.path.append(os.path.join( |
import errors |
-TESTING = 'BUILDBOT_TESTING' in os.environ |
- |
CHROME_SRC = constants.CHROME_DIR |
# Describes an instrumation test suite: |
@@ -62,35 +63,6 @@ INSTRUMENTATION_TESTS = dict((suite.name, suite) for suite in [ |
VALID_TESTS = set(['chromedriver', 'ui', 'unit', 'webkit', 'webkit_layout']) |
-def SpawnCmd(command): |
- """Spawn a process without waiting for termination.""" |
- print '>', ' '.join(map(pipes.quote, command)) |
- sys.stdout.flush() |
- if TESTING: |
- class MockPopen(object): |
- @staticmethod |
- def wait(): |
- return 0 |
- return MockPopen() |
- |
- return subprocess.Popen(command, cwd=CHROME_SRC) |
- |
-def RunCmd(command, flunk_on_failure=True, halt_on_failure=False): |
- """Run a command relative to the chrome source root.""" |
- code = SpawnCmd(command).wait() |
- print '<', ' '.join(map(pipes.quote, command)) |
- if code != 0: |
- print 'ERROR: process exited with code %d' % code |
- if flunk_on_failure: |
- buildbot_report.PrintError() |
- else: |
- buildbot_report.PrintWarning() |
- # Allow steps to have both halting (i.e. 1) and non-halting exit codes. |
- if code != 0 and code != 88 and halt_on_failure: |
- raise OSError() |
- return code |
- |
- |
# multiprocessing map_async requires a top-level function for pickle library. |
def RebootDeviceSafe(device): |
"""Reboot a device, wait for it to start, and squelch timeout exceptions.""" |
@@ -324,19 +296,17 @@ def MainTestWrapper(options): |
def main(argv): |
+ buildbot_report.PrintNamedStep('Run tests') |
parser = optparse.OptionParser() |
- def convert_json(option, _, value, parser): |
- setattr(parser.values, option.dest, json.loads(value)) |
- |
parser.add_option('--build-properties', action='callback', |
Isaac (away)
2013/05/29 20:28:07
let's make a function in bb_utils "GetParser()" wh
Siva Chandra
2013/06/04 00:34:03
Done.
|
- callback=convert_json, type='string', default={}, |
+ callback=ConvertJson, type='string', default={}, |
help='build properties in JSON format') |
parser.add_option('--factory-properties', action='callback', |
- callback=convert_json, type='string', default={}, |
+ callback=ConvertJson, type='string', default={}, |
help='factory properties in JSON format') |
parser.add_option('--slave-properties', action='callback', |
- callback=convert_json, type='string', default={}, |
+ callback=ConvertJson, type='string', default={}, |
help='Properties set by slave script in JSON format') |
parser.add_option('--experimental', action='store_true', |
help='Run experiemental tests') |
@@ -356,18 +326,12 @@ def main(argv): |
help='Push script to device which restarts adbd on disconnections.') |
options, args = parser.parse_args(argv[1:]) |
- def ParserError(msg): |
- """We avoid parser.error because it calls sys.exit.""" |
- parser.print_help() |
- print >> sys.stderr, '\nERROR:', msg |
- return 1 |
- |
if args: |
- return ParserError('Unused args %s' % args) |
+ return OptParserError(parser, 'Unused args %s' % args) |
Isaac (away)
2013/05/29 20:28:07
GetParser should be able to return a parser with a
Siva Chandra
2013/06/04 00:34:03
Done.
|
unknown_tests = set(options.test_filter) - VALID_TESTS |
if unknown_tests: |
- return ParserError('Unknown tests %s' % list(unknown_tests)) |
+ return OptParserError(parser, 'Unknown tests %s' % list(unknown_tests)) |
setattr(options, 'target', options.factory_properties.get('target', 'Debug')) |