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

Side by Side Diff: build/android/gyp/create_test_runner_script.py

Issue 2562063003: Add incremental_apk_by_default GN arg. (Closed)
Patch Set: Remove error formatting Created 4 years 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
« no previous file with comments | « no previous file | build/config/android/config.gni » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2015 The Chromium Authors. All rights reserved. 3 # Copyright 2015 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Creates a script to run an android test using build/android/test_runner.py. 7 """Creates a script to run an android test using build/android/test_runner.py.
8 """ 8 """
9 9
10 import argparse 10 import argparse
11 import os 11 import os
12 import re
12 import sys 13 import sys
13 14
14 from util import build_utils 15 from util import build_utils
15 16
16 SCRIPT_TEMPLATE = """\ 17 SCRIPT_TEMPLATE = """\
17 #!/usr/bin/env python 18 #!/usr/bin/env python
18 # 19 #
19 # This file was generated by build/android/gyp/create_test_runner_script.py 20 # This file was generated by build/android/gyp/create_test_runner_script.py
20 21
21 import os 22 import os
(...skipping 13 matching lines...) Expand all
35 for arg, path in test_runner_path_args: 36 for arg, path in test_runner_path_args:
36 test_runner_args.extend([arg, ResolvePath(path)]) 37 test_runner_args.extend([arg, ResolvePath(path)])
37 38
38 os.execv(test_runner_path, 39 os.execv(test_runner_path,
39 [test_runner_path] + test_runner_args + sys.argv[1:]) 40 [test_runner_path] + test_runner_args + sys.argv[1:])
40 41
41 if __name__ == '__main__': 42 if __name__ == '__main__':
42 sys.exit(main()) 43 sys.exit(main())
43 """ 44 """
44 45
46
47 def _GenerateAdditionalApksErrorString(incremental_apks):
48 err_string = ('Apks that are listed as additional_apks for '
49 'another target cannot be incremental. Please add never_incremental to '
50 'the following apks: %s')
51 return err_string % ', '.join(a for a in incremental_apks)
52
53
45 def main(args): 54 def main(args):
46 parser = argparse.ArgumentParser() 55 parser = argparse.ArgumentParser()
47 parser.add_argument('--script-output-path', 56 parser.add_argument('--script-output-path',
48 help='Output path for executable script.') 57 help='Output path for executable script.')
49 parser.add_argument('--depfile', 58 parser.add_argument('--depfile',
50 help='Path to the depfile. This must be specified as ' 59 help='Path to the depfile. This must be specified as '
51 "the action's first output.") 60 "the action's first output.")
52 parser.add_argument('--test-runner-path', 61 parser.add_argument('--test-runner-path',
53 help='Path to test_runner.py (optional).') 62 help='Path to test_runner.py (optional).')
54 # We need to intercept any test runner path arguments and make all 63 # We need to intercept any test runner path arguments and make all
55 # of the paths relative to the output script directory. 64 # of the paths relative to the output script directory.
56 group = parser.add_argument_group('Test runner path arguments.') 65 group = parser.add_argument_group('Test runner path arguments.')
57 group.add_argument('--additional-apk', action='append', 66 group.add_argument('--additional-apk', action='append',
58 dest='additional_apks', default=[]) 67 dest='additional_apks', default=[])
59 group.add_argument('--additional-apk-list') 68 group.add_argument('--additional-apk-list')
69 group.add_argument('--additional-apk-incremental', action='append',
70 dest='additional_apks_incremental', default=[])
60 group.add_argument('--apk-under-test') 71 group.add_argument('--apk-under-test')
61 group.add_argument('--apk-under-test-incremental-install-script') 72 group.add_argument('--apk-under-test-incremental-install-script')
62 group.add_argument('--executable-dist-dir') 73 group.add_argument('--executable-dist-dir')
63 group.add_argument('--isolate-file-path') 74 group.add_argument('--isolate-file-path')
64 group.add_argument('--output-directory') 75 group.add_argument('--output-directory')
65 group.add_argument('--runtime-deps-path') 76 group.add_argument('--runtime-deps-path')
66 group.add_argument('--test-apk') 77 group.add_argument('--test-apk')
67 group.add_argument('--test-jar') 78 group.add_argument('--test-jar')
68 group.add_argument('--test-apk-incremental-install-script') 79 group.add_argument('--test-apk-incremental-install-script')
69 group.add_argument('--coverage-dir') 80 group.add_argument('--coverage-dir')
70 args, test_runner_args = parser.parse_known_args( 81 args, test_runner_args = parser.parse_known_args(
71 build_utils.ExpandFileArgs(args)) 82 build_utils.ExpandFileArgs(args))
72 83
73 def RelativizePathToScript(path): 84 def RelativizePathToScript(path):
74 """Returns the path relative to the output script directory.""" 85 """Returns the path relative to the output script directory."""
75 return os.path.relpath(path, os.path.dirname(args.script_output_path)) 86 return os.path.relpath(path, os.path.dirname(args.script_output_path))
76 87
77 test_runner_path = args.test_runner_path or os.path.join( 88 test_runner_path = args.test_runner_path or os.path.join(
78 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') 89 os.path.dirname(__file__), os.path.pardir, 'test_runner.py')
79 test_runner_path = RelativizePathToScript(test_runner_path) 90 test_runner_path = RelativizePathToScript(test_runner_path)
80 91
81 test_runner_path_args = [] 92 test_runner_path_args = []
82 if args.additional_apk_list: 93 if args.additional_apk_list:
83 args.additional_apks.extend( 94 args.additional_apks.extend(
84 build_utils.ParseGnList(args.additional_apk_list)) 95 build_utils.ParseGnList(args.additional_apk_list))
85 if args.additional_apks: 96 if args.additional_apks:
86 test_runner_path_args.extend( 97 test_runner_path_args.extend(
87 ('--additional-apk', RelativizePathToScript(a)) 98 ('--additional-apk', RelativizePathToScript(a))
88 for a in args.additional_apks) 99 for a in args.additional_apks)
100 if args.additional_apks_incremental:
101 bad_additional_apks = [a for a in args.additional_apks_incremental
102 if a != 'None']
103 if bad_additional_apks:
104 raise Exception(_GenerateAdditionalApksErrorString(bad_additional_apks))
89 if args.apk_under_test: 105 if args.apk_under_test:
90 test_runner_path_args.append( 106 test_runner_path_args.append(
91 ('--apk-under-test', RelativizePathToScript(args.apk_under_test))) 107 ('--apk-under-test', RelativizePathToScript(args.apk_under_test)))
92 if args.apk_under_test_incremental_install_script: 108 if args.apk_under_test_incremental_install_script:
93 test_runner_path_args.append( 109 test_runner_path_args.append(
94 ('--apk-under-test-incremental-install-script', 110 ('--apk-under-test-incremental-install-script',
95 RelativizePathToScript( 111 RelativizePathToScript(
96 args.apk_under_test_incremental_install_script))) 112 args.apk_under_test_incremental_install_script)))
97 if args.executable_dist_dir: 113 if args.executable_dist_dir:
98 test_runner_path_args.append( 114 test_runner_path_args.append(
(...skipping 28 matching lines...) Expand all
127 test_runner_args=str(test_runner_args), 143 test_runner_args=str(test_runner_args),
128 test_runner_path_args=str(test_runner_path_args))) 144 test_runner_path_args=str(test_runner_path_args)))
129 145
130 os.chmod(args.script_output_path, 0750) 146 os.chmod(args.script_output_path, 0750)
131 147
132 if args.depfile: 148 if args.depfile:
133 build_utils.WriteDepfile(args.depfile, args.script_output_path) 149 build_utils.WriteDepfile(args.depfile, args.script_output_path)
134 150
135 if __name__ == '__main__': 151 if __name__ == '__main__':
136 sys.exit(main(sys.argv[1:])) 152 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/config/android/config.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698