| 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 | |
| 64 # 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 |
| 65 # of the paths relative to the output script directory. | 64 # of the paths relative to the output script directory. |
| 66 group = parser.add_argument_group('Test runner path arguments.') | 65 group = parser.add_argument_group('Test runner path arguments.') |
| 67 group.add_argument('--additional-apk', action='append', | 66 group.add_argument('--additional-apk', action='append', |
| 68 dest='additional_apks', default=[]) | 67 dest='additional_apks', default=[]) |
| 69 group.add_argument('--additional-apk-list') | 68 group.add_argument('--additional-apk-list') |
| 70 group.add_argument('--additional-apk-incremental', action='append', | 69 group.add_argument('--additional-apk-incremental', action='append', |
| 71 dest='additional_apks_incremental', default=[]) | 70 dest='additional_apks_incremental', default=[]) |
| 72 group.add_argument('--apk-under-test') | 71 group.add_argument('--apk-under-test') |
| 73 group.add_argument('--apk-under-test-incremental-install-script') | 72 group.add_argument('--apk-under-test-incremental-install-script') |
| 74 group.add_argument('--executable-dist-dir') | 73 group.add_argument('--executable-dist-dir') |
| 75 group.add_argument('--isolate-file-path') | 74 group.add_argument('--isolate-file-path') |
| 76 group.add_argument('--output-directory') | 75 group.add_argument('--output-directory') |
| 77 group.add_argument('--runtime-deps-path') | 76 group.add_argument('--runtime-deps-path') |
| 78 group.add_argument('--test-apk') | 77 group.add_argument('--test-apk') |
| 79 group.add_argument('--test-jar') | 78 group.add_argument('--test-jar') |
| 80 group.add_argument('--test-apk-incremental-install-script') | 79 group.add_argument('--test-apk-incremental-install-script') |
| 81 group.add_argument('--coverage-dir') | 80 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') | |
| 85 args, test_runner_args = parser.parse_known_args( | 81 args, test_runner_args = parser.parse_known_args( |
| 86 build_utils.ExpandFileArgs(args)) | 82 build_utils.ExpandFileArgs(args)) |
| 87 | 83 |
| 88 def RelativizePathToScript(path): | 84 def RelativizePathToScript(path): |
| 89 """Returns the path relative to the output script directory.""" | 85 """Returns the path relative to the output script directory.""" |
| 90 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)) |
| 91 | 87 |
| 92 test_runner_path = args.test_runner_path or os.path.join( | 88 test_runner_path = args.test_runner_path or os.path.join( |
| 93 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') | 89 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') |
| 94 test_runner_path = RelativizePathToScript(test_runner_path) | 90 test_runner_path = RelativizePathToScript(test_runner_path) |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if args.test_jar: | 129 if args.test_jar: |
| 134 test_runner_path_args.append( | 130 test_runner_path_args.append( |
| 135 ('--test-jar', RelativizePathToScript(args.test_jar))) | 131 ('--test-jar', RelativizePathToScript(args.test_jar))) |
| 136 if args.test_apk_incremental_install_script: | 132 if args.test_apk_incremental_install_script: |
| 137 test_runner_path_args.append( | 133 test_runner_path_args.append( |
| 138 ('--test-apk-incremental-install-script', | 134 ('--test-apk-incremental-install-script', |
| 139 RelativizePathToScript(args.test_apk_incremental_install_script))) | 135 RelativizePathToScript(args.test_apk_incremental_install_script))) |
| 140 if args.coverage_dir: | 136 if args.coverage_dir: |
| 141 test_runner_path_args.append( | 137 test_runner_path_args.append( |
| 142 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) | 138 ('--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))) | |
| 155 | 139 |
| 156 with open(args.script_output_path, 'w') as script: | 140 with open(args.script_output_path, 'w') as script: |
| 157 script.write(SCRIPT_TEMPLATE.format( | 141 script.write(SCRIPT_TEMPLATE.format( |
| 158 test_runner_path=str(test_runner_path), | 142 test_runner_path=str(test_runner_path), |
| 159 test_runner_args=str(test_runner_args), | 143 test_runner_args=str(test_runner_args), |
| 160 test_runner_path_args=str(test_runner_path_args))) | 144 test_runner_path_args=str(test_runner_path_args))) |
| 161 | 145 |
| 162 os.chmod(args.script_output_path, 0750) | 146 os.chmod(args.script_output_path, 0750) |
| 163 | 147 |
| 164 if args.depfile: | 148 if args.depfile: |
| 165 build_utils.WriteDepfile(args.depfile, args.script_output_path) | 149 build_utils.WriteDepfile(args.depfile, args.script_output_path) |
| 166 | 150 |
| 167 if __name__ == '__main__': | 151 if __name__ == '__main__': |
| 168 sys.exit(main(sys.argv[1:])) | 152 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |