OLD | NEW |
---|---|
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 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
53 | 53 |
54 def main(args): | 54 def main(args): |
55 parser = argparse.ArgumentParser() | 55 parser = argparse.ArgumentParser() |
56 parser.add_argument('--script-output-path', | 56 parser.add_argument('--script-output-path', |
57 help='Output path for executable script.') | 57 help='Output path for executable script.') |
58 parser.add_argument('--depfile', | 58 parser.add_argument('--depfile', |
59 help='Path to the depfile. This must be specified as ' | 59 help='Path to the depfile. This must be specified as ' |
60 "the action's first output.") | 60 "the action's first output.") |
61 parser.add_argument('--test-runner-path', | 61 parser.add_argument('--test-runner-path', |
62 help='Path to test_runner.py (optional).') | 62 help='Path to test_runner.py (optional).') |
63 | |
63 # We need to intercept any test runner path arguments and make all | 64 # We need to intercept any test runner path arguments and make all |
64 # of the paths relative to the output script directory. | 65 # of the paths relative to the output script directory. |
65 group = parser.add_argument_group('Test runner path arguments.') | 66 group = parser.add_argument_group('Test runner path arguments.') |
66 group.add_argument('--additional-apk', action='append', | 67 group.add_argument('--additional-apk', action='append', |
67 dest='additional_apks', default=[]) | 68 dest='additional_apks', default=[]) |
68 group.add_argument('--additional-apk-list') | 69 group.add_argument('--additional-apk-list') |
69 group.add_argument('--additional-apk-incremental', action='append', | 70 group.add_argument('--additional-apk-incremental', action='append', |
70 dest='additional_apks_incremental', default=[]) | 71 dest='additional_apks_incremental', default=[]) |
71 group.add_argument('--apk-under-test') | 72 group.add_argument('--apk-under-test') |
72 group.add_argument('--apk-under-test-incremental-install-script') | 73 group.add_argument('--apk-under-test-incremental-install-script') |
73 group.add_argument('--executable-dist-dir') | 74 group.add_argument('--executable-dist-dir') |
74 group.add_argument('--isolate-file-path') | 75 group.add_argument('--isolate-file-path') |
75 group.add_argument('--output-directory') | 76 group.add_argument('--output-directory') |
76 group.add_argument('--runtime-deps-path') | 77 group.add_argument('--runtime-deps-path') |
77 group.add_argument('--test-apk') | 78 group.add_argument('--test-apk') |
78 group.add_argument('--test-jar') | 79 group.add_argument('--test-jar') |
79 group.add_argument('--test-apk-incremental-install-script') | 80 group.add_argument('--test-apk-incremental-install-script') |
80 group.add_argument('--coverage-dir') | 81 group.add_argument('--coverage-dir') |
82 group.add_argument('--android-manifest-path') | |
83 group.add_argument('--resource-dir', action='append', | |
84 dest='resource_dirs', default=[]) | |
85 group.add_argument('--robolectric-runtime-deps-dir') | |
81 args, test_runner_args = parser.parse_known_args( | 86 args, test_runner_args = parser.parse_known_args( |
82 build_utils.ExpandFileArgs(args)) | 87 build_utils.ExpandFileArgs(args)) |
83 | 88 |
84 def RelativizePathToScript(path): | 89 def RelativizePathToScript(path): |
85 """Returns the path relative to the output script directory.""" | 90 """Returns the path relative to the output script directory.""" |
86 return os.path.relpath(path, os.path.dirname(args.script_output_path)) | 91 return os.path.relpath(path, os.path.dirname(args.script_output_path)) |
87 | 92 |
88 test_runner_path = args.test_runner_path or os.path.join( | 93 test_runner_path = args.test_runner_path or os.path.join( |
89 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') | 94 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') |
90 test_runner_path = RelativizePathToScript(test_runner_path) | 95 test_runner_path = RelativizePathToScript(test_runner_path) |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
129 if args.test_jar: | 134 if args.test_jar: |
130 test_runner_path_args.append( | 135 test_runner_path_args.append( |
131 ('--test-jar', RelativizePathToScript(args.test_jar))) | 136 ('--test-jar', RelativizePathToScript(args.test_jar))) |
132 if args.test_apk_incremental_install_script: | 137 if args.test_apk_incremental_install_script: |
133 test_runner_path_args.append( | 138 test_runner_path_args.append( |
134 ('--test-apk-incremental-install-script', | 139 ('--test-apk-incremental-install-script', |
135 RelativizePathToScript(args.test_apk_incremental_install_script))) | 140 RelativizePathToScript(args.test_apk_incremental_install_script))) |
136 if args.coverage_dir: | 141 if args.coverage_dir: |
137 test_runner_path_args.append( | 142 test_runner_path_args.append( |
138 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) | 143 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) |
144 if args.android_manifest_path: | |
145 test_runner_path_args.append( | |
146 ('--android-manifest-path', | |
147 RelativizePathToScript(args.android_manifest_path))) | |
148 if args.resource_dirs: | |
149 test_runner_path_args.extend( | |
150 ('--resource-dir', RelativizePathToScript(r)) | |
151 for r in args.resource_dirs) | |
152 if args.robolectric_runtime_deps_dir: | |
jbudorick
2017/03/30 19:11:44
Separate CL idea: there has to be a way to do this
| |
153 test_runner_path_args.append( | |
154 ('--robolectric-runtime-deps-dir', | |
155 RelativizePathToScript(args.robolectric_runtime_deps_dir))) | |
139 | 156 |
140 with open(args.script_output_path, 'w') as script: | 157 with open(args.script_output_path, 'w') as script: |
141 script.write(SCRIPT_TEMPLATE.format( | 158 script.write(SCRIPT_TEMPLATE.format( |
142 test_runner_path=str(test_runner_path), | 159 test_runner_path=str(test_runner_path), |
143 test_runner_args=str(test_runner_args), | 160 test_runner_args=str(test_runner_args), |
144 test_runner_path_args=str(test_runner_path_args))) | 161 test_runner_path_args=str(test_runner_path_args))) |
145 | 162 |
146 os.chmod(args.script_output_path, 0750) | 163 os.chmod(args.script_output_path, 0750) |
147 | 164 |
148 if args.depfile: | 165 if args.depfile: |
149 build_utils.WriteDepfile(args.depfile, args.script_output_path) | 166 build_utils.WriteDepfile(args.depfile, args.script_output_path) |
150 | 167 |
151 if __name__ == '__main__': | 168 if __name__ == '__main__': |
152 sys.exit(main(sys.argv[1:])) | 169 sys.exit(main(sys.argv[1:])) |
OLD | NEW |