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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 # of the paths relative to the output script directory. | 55 # of the paths relative to the output script directory. |
56 group = parser.add_argument_group('Test runner path arguments.') | 56 group = parser.add_argument_group('Test runner path arguments.') |
57 group.add_argument('--additional-apk', action='append', | 57 group.add_argument('--additional-apk', action='append', |
58 dest='additional_apks', default=[]) | 58 dest='additional_apks', default=[]) |
59 group.add_argument('--additional-apk-list') | 59 group.add_argument('--additional-apk-list') |
60 group.add_argument('--apk-under-test') | 60 group.add_argument('--apk-under-test') |
61 group.add_argument('--apk-under-test-incremental-install-script') | 61 group.add_argument('--apk-under-test-incremental-install-script') |
62 group.add_argument('--executable-dist-dir') | 62 group.add_argument('--executable-dist-dir') |
63 group.add_argument('--isolate-file-path') | 63 group.add_argument('--isolate-file-path') |
64 group.add_argument('--output-directory') | 64 group.add_argument('--output-directory') |
65 group.add_argument('--runtime-deps-path') | |
66 group.add_argument('--test-apk') | 65 group.add_argument('--test-apk') |
67 group.add_argument('--test-apk-incremental-install-script') | 66 group.add_argument('--test-apk-incremental-install-script') |
68 group.add_argument('--coverage-dir') | 67 group.add_argument('--coverage-dir') |
69 args, test_runner_args = parser.parse_known_args( | 68 args, test_runner_args = parser.parse_known_args( |
70 build_utils.ExpandFileArgs(args)) | 69 build_utils.ExpandFileArgs(args)) |
71 | 70 |
72 def RelativizePathToScript(path): | 71 def RelativizePathToScript(path): |
73 """Returns the path relative to the output script directory.""" | 72 """Returns the path relative to the output script directory.""" |
74 return os.path.relpath(path, os.path.dirname(args.script_output_path)) | 73 return os.path.relpath(path, os.path.dirname(args.script_output_path)) |
75 | 74 |
(...skipping 20 matching lines...) Expand all Loading... |
96 if args.executable_dist_dir: | 95 if args.executable_dist_dir: |
97 test_runner_path_args.append( | 96 test_runner_path_args.append( |
98 ('--executable-dist-dir', | 97 ('--executable-dist-dir', |
99 RelativizePathToScript(args.executable_dist_dir))) | 98 RelativizePathToScript(args.executable_dist_dir))) |
100 if args.isolate_file_path: | 99 if args.isolate_file_path: |
101 test_runner_path_args.append( | 100 test_runner_path_args.append( |
102 ('--isolate-file-path', RelativizePathToScript(args.isolate_file_path))) | 101 ('--isolate-file-path', RelativizePathToScript(args.isolate_file_path))) |
103 if args.output_directory: | 102 if args.output_directory: |
104 test_runner_path_args.append( | 103 test_runner_path_args.append( |
105 ('--output-directory', RelativizePathToScript(args.output_directory))) | 104 ('--output-directory', RelativizePathToScript(args.output_directory))) |
106 if args.runtime_deps_path: | |
107 test_runner_path_args.append( | |
108 ('--runtime-deps-path', RelativizePathToScript(args.runtime_deps_path))) | |
109 if args.test_apk: | 105 if args.test_apk: |
110 test_runner_path_args.append( | 106 test_runner_path_args.append( |
111 ('--test-apk', RelativizePathToScript(args.test_apk))) | 107 ('--test-apk', RelativizePathToScript(args.test_apk))) |
112 if args.test_apk_incremental_install_script: | 108 if args.test_apk_incremental_install_script: |
113 test_runner_path_args.append( | 109 test_runner_path_args.append( |
114 ('--test-apk-incremental-install-script', | 110 ('--test-apk-incremental-install-script', |
115 RelativizePathToScript(args.test_apk_incremental_install_script))) | 111 RelativizePathToScript(args.test_apk_incremental_install_script))) |
116 if args.coverage_dir: | 112 if args.coverage_dir: |
117 test_runner_path_args.append( | 113 test_runner_path_args.append( |
118 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) | 114 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) |
119 | 115 |
120 with open(args.script_output_path, 'w') as script: | 116 with open(args.script_output_path, 'w') as script: |
121 script.write(SCRIPT_TEMPLATE.format( | 117 script.write(SCRIPT_TEMPLATE.format( |
122 test_runner_path=str(test_runner_path), | 118 test_runner_path=str(test_runner_path), |
123 test_runner_args=str(test_runner_args), | 119 test_runner_args=str(test_runner_args), |
124 test_runner_path_args=str(test_runner_path_args))) | 120 test_runner_path_args=str(test_runner_path_args))) |
125 | 121 |
126 os.chmod(args.script_output_path, 0750) | 122 os.chmod(args.script_output_path, 0750) |
127 | 123 |
128 if args.depfile: | 124 if args.depfile: |
129 build_utils.WriteDepfile(args.depfile, args.script_output_path) | 125 build_utils.WriteDepfile(args.depfile, args.script_output_path) |
130 | 126 |
131 if __name__ == '__main__': | 127 if __name__ == '__main__': |
132 sys.exit(main(sys.argv[1:])) | 128 sys.exit(main(sys.argv[1:])) |
OLD | NEW |