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

Side by Side Diff: build/android/pylib/test_options_parser.py

Issue 10836323: Change Android build configurations (step 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed unnecessary changes Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « build/android/pylib/single_test_runner.py ('k') | build/android/run_tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Parses options for the instrumentation tests.""" 5 """Parses options for the instrumentation tests."""
6 6
7 import constants 7 import constants
8 import optparse 8 import optparse
9 import os 9 import os
10 10
11 _SDK_OUT_DIR = os.path.join(constants.CHROME_DIR, 'out')
12
13
14 def AddBuildTypeOption(option_parser):
15 # TODO(wangxianzhu): Change to Debug when we build Debug by default.
16 default_build_type = 'Release'
17 if 'BUILDTYPE' in os.environ:
18 default_build_type = os.environ['BUILDTYPE']
19 option_parser.add_option('--debug', action='store_const', const='Debug',
20 dest='build_type', default=default_build_type,
21 help='If set, run test suites under out/Debug.')
22 option_parser.add_option('--release', action='store_const', const='Release',
23 dest='build_type',
24 help='If set, run test suites under out/Release.')
11 25
12 26
13 def CreateTestRunnerOptionParser(usage=None, default_timeout=60): 27 def CreateTestRunnerOptionParser(usage=None, default_timeout=60):
14 """Returns a new OptionParser with arguments applicable to all tests.""" 28 """Returns a new OptionParser with arguments applicable to all tests."""
15 option_parser = optparse.OptionParser(usage=usage) 29 option_parser = optparse.OptionParser(usage=usage)
16 option_parser.add_option('-t', dest='timeout', 30 option_parser.add_option('-t', dest='timeout',
17 help='Timeout to wait for each test', 31 help='Timeout to wait for each test',
18 type='int', 32 type='int',
19 default=default_timeout) 33 default=default_timeout)
20 option_parser.add_option('-c', dest='cleanup_test_files', 34 option_parser.add_option('-c', dest='cleanup_test_files',
21 help='Cleanup test files on the device after run', 35 help='Cleanup test files on the device after run',
22 action='store_true') 36 action='store_true')
23 option_parser.add_option('-v', 37 option_parser.add_option('-v',
24 '--verbose', 38 '--verbose',
25 dest='verbose_count', 39 dest='verbose_count',
26 default=0, 40 default=0,
27 action='count', 41 action='count',
28 help='Verbose level (multiple times for more)') 42 help='Verbose level (multiple times for more)')
29 profilers = ['devicestatsmonitor', 'chrometrace', 'dumpheap', 'smaps', 43 profilers = ['devicestatsmonitor', 'chrometrace', 'dumpheap', 'smaps',
30 'traceview'] 44 'traceview']
31 option_parser.add_option('--profiler', dest='profilers', action='append', 45 option_parser.add_option('--profiler', dest='profilers', action='append',
32 choices=profilers, 46 choices=profilers,
33 help='Profiling tool to run during test. ' 47 help='Profiling tool to run during test. '
34 'Pass multiple times to run multiple profilers. ' 48 'Pass multiple times to run multiple profilers. '
35 'Available profilers: %s' % profilers) 49 'Available profilers: %s' % profilers)
36 option_parser.add_option('--tool', 50 option_parser.add_option('--tool',
37 dest='tool', 51 dest='tool',
38 help='Run the test under a tool ' 52 help='Run the test under a tool '
39 '(use --tool help to list them)') 53 '(use --tool help to list them)')
54 AddBuildTypeOption(option_parser)
40 return option_parser 55 return option_parser
41 56
42 57
43 def ParseInstrumentationArgs(args): 58 def ParseInstrumentationArgs(args):
44 """Parse arguments and return options with defaults.""" 59 """Parse arguments and return options with defaults."""
45 60
46 option_parser = CreateTestRunnerOptionParser() 61 option_parser = CreateTestRunnerOptionParser()
47 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger', 62 option_parser.add_option('-w', '--wait_debugger', dest='wait_for_debugger',
48 action='store_true', help='Wait for debugger.') 63 action='store_true', help='Wait for debugger.')
49 option_parser.add_option('-I', dest='install_apk', help='Install APK.', 64 option_parser.add_option('-I', dest='install_apk', help='Install APK.',
(...skipping 11 matching lines...) Expand all
61 option_parser.add_option('-j', '--java_only', action='store_true', 76 option_parser.add_option('-j', '--java_only', action='store_true',
62 help='Run only the Java tests.') 77 help='Run only the Java tests.')
63 option_parser.add_option('-p', '--python_only', action='store_true', 78 option_parser.add_option('-p', '--python_only', action='store_true',
64 help='Run only the Python tests.') 79 help='Run only the Python tests.')
65 option_parser.add_option('-n', '--run_count', type='int', 80 option_parser.add_option('-n', '--run_count', type='int',
66 dest='number_of_runs', default=1, 81 dest='number_of_runs', default=1,
67 help=('How many times to run each test, regardless ' 82 help=('How many times to run each test, regardless '
68 'of the result. (Default is 1)')) 83 'of the result. (Default is 1)'))
69 option_parser.add_option('--test-apk', dest='test_apk', 84 option_parser.add_option('--test-apk', dest='test_apk',
70 help=('The name of the apk containing the tests ' 85 help=('The name of the apk containing the tests '
71 '(without the .apk extension).')) 86 '(without the .apk extension) or for SDK '
87 'builds, the path to the APK from '
88 'out/(Debug|Release) (for example, '
89 'content_shell_test/ContentShellTest-debug).'))
72 option_parser.add_option('--screenshot', dest='screenshot_failures', 90 option_parser.add_option('--screenshot', dest='screenshot_failures',
73 action='store_true', 91 action='store_true',
74 help='Capture screenshots of test failures') 92 help='Capture screenshots of test failures')
75 option_parser.add_option('--save-perf-json', action='store_true', 93 option_parser.add_option('--save-perf-json', action='store_true',
76 help='Saves the JSON file for each UI Perf test.') 94 help='Saves the JSON file for each UI Perf test.')
77 option_parser.add_option('--shard_retries', type=int, default=1, 95 option_parser.add_option('--shard_retries', type=int, default=1,
78 help=('Number of times to retry each failure when ' 96 help=('Number of times to retry each failure when '
79 'sharding.')) 97 'sharding.'))
80 option_parser.add_option('--official-build', help='Run official build tests.') 98 option_parser.add_option('--official-build', help='Run official build tests.')
81 option_parser.add_option('--device', 99 option_parser.add_option('--device',
82 help='Serial number of device we should use.') 100 help='Serial number of device we should use.')
83 option_parser.add_option('--python_test_root', 101 option_parser.add_option('--python_test_root',
84 help='Root of the python-driven tests.') 102 help='Root of the python-driven tests.')
85 103
86 options, args = option_parser.parse_args(args) 104 options, args = option_parser.parse_args(args)
87 if len(args) > 1: 105 if len(args) > 1:
88 option_parser.error('Unknown argument:', args[1:]) 106 option_parser.error('Unknown argument:', args[1:])
89 if options.java_only and options.python_only: 107 if options.java_only and options.python_only:
90 option_parser.error('Options java_only (-j) and python_only (-p) ' 108 option_parser.error('Options java_only (-j) and python_only (-p) '
91 'are mutually exclusive') 109 'are mutually exclusive')
92 110
93 options.run_java_tests = True 111 options.run_java_tests = True
94 options.run_python_tests = True 112 options.run_python_tests = True
95 if options.java_only: 113 if options.java_only:
96 options.run_python_tests = False 114 options.run_python_tests = False
97 elif options.python_only: 115 elif options.python_only:
98 options.run_java_tests = False 116 options.run_java_tests = False
99 117
100 options.test_apk_path = os.path.join(constants.CHROME_DIR, 118 options.test_apk_path = os.path.join(_SDK_OUT_DIR,
101 'out', 'Release', 119 options.build_type,
102 '%s.apk' % options.test_apk) 120 '%s.apk' % options.test_apk)
103 options.test_apk_jar_path = os.path.join(constants.CHROME_DIR, 121 options.test_apk_jar_path = os.path.join(_SDK_OUT_DIR,
104 'out', 'Release', 122 options.build_type,
105 '%s.jar' % options.test_apk) 123 '%s.jar'
124 % options.test_apk)
106 if options.annotation_str: 125 if options.annotation_str:
107 options.annotation = options.annotation_str.split() 126 options.annotation = options.annotation_str.split()
108 elif options.test_filter: 127 elif options.test_filter:
109 options.annotation = [] 128 options.annotation = []
110 else: 129 else:
111 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest'] 130 options.annotation = ['Smoke', 'SmallTest', 'MediumTest', 'LargeTest']
112 131
113 return options 132 return options
OLDNEW
« no previous file with comments | « build/android/pylib/single_test_runner.py ('k') | build/android/run_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698