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-zips') |
| 84 group.add_argument('--robolectric-runtime-deps-dir') |
81 args, test_runner_args = parser.parse_known_args( | 85 args, test_runner_args = parser.parse_known_args( |
82 build_utils.ExpandFileArgs(args)) | 86 build_utils.ExpandFileArgs(args)) |
83 | 87 |
84 def RelativizePathToScript(path): | 88 def RelativizePathToScript(path): |
85 """Returns the path relative to the output script directory.""" | 89 """Returns the path relative to the output script directory.""" |
86 return os.path.relpath(path, os.path.dirname(args.script_output_path)) | 90 return os.path.relpath(path, os.path.dirname(args.script_output_path)) |
87 | 91 |
88 test_runner_path = args.test_runner_path or os.path.join( | 92 test_runner_path = args.test_runner_path or os.path.join( |
89 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') | 93 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') |
90 test_runner_path = RelativizePathToScript(test_runner_path) | 94 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: | 133 if args.test_jar: |
130 test_runner_path_args.append( | 134 test_runner_path_args.append( |
131 ('--test-jar', RelativizePathToScript(args.test_jar))) | 135 ('--test-jar', RelativizePathToScript(args.test_jar))) |
132 if args.test_apk_incremental_install_script: | 136 if args.test_apk_incremental_install_script: |
133 test_runner_path_args.append( | 137 test_runner_path_args.append( |
134 ('--test-apk-incremental-install-script', | 138 ('--test-apk-incremental-install-script', |
135 RelativizePathToScript(args.test_apk_incremental_install_script))) | 139 RelativizePathToScript(args.test_apk_incremental_install_script))) |
136 if args.coverage_dir: | 140 if args.coverage_dir: |
137 test_runner_path_args.append( | 141 test_runner_path_args.append( |
138 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) | 142 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) |
| 143 if args.android_manifest_path: |
| 144 test_runner_path_args.append( |
| 145 ('--android-manifest-path', |
| 146 RelativizePathToScript(args.android_manifest_path))) |
| 147 if args.resource_zips: |
| 148 test_runner_path_args.extend( |
| 149 ('--resource-zip', RelativizePathToScript(r)) |
| 150 for r in build_utils.ParseGnList(args.resource_zips)) |
| 151 if args.robolectric_runtime_deps_dir: |
| 152 test_runner_path_args.append( |
| 153 ('--robolectric-runtime-deps-dir', |
| 154 RelativizePathToScript(args.robolectric_runtime_deps_dir))) |
139 | 155 |
140 with open(args.script_output_path, 'w') as script: | 156 with open(args.script_output_path, 'w') as script: |
141 script.write(SCRIPT_TEMPLATE.format( | 157 script.write(SCRIPT_TEMPLATE.format( |
142 test_runner_path=str(test_runner_path), | 158 test_runner_path=str(test_runner_path), |
143 test_runner_args=str(test_runner_args), | 159 test_runner_args=str(test_runner_args), |
144 test_runner_path_args=str(test_runner_path_args))) | 160 test_runner_path_args=str(test_runner_path_args))) |
145 | 161 |
146 os.chmod(args.script_output_path, 0750) | 162 os.chmod(args.script_output_path, 0750) |
147 | 163 |
148 if args.depfile: | 164 if args.depfile: |
149 build_utils.WriteDepfile(args.depfile, args.script_output_path) | 165 build_utils.WriteDepfile(args.depfile, args.script_output_path) |
150 | 166 |
151 if __name__ == '__main__': | 167 if __name__ == '__main__': |
152 sys.exit(main(sys.argv[1:])) | 168 sys.exit(main(sys.argv[1:])) |
OLD | NEW |