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