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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 parser.add_argument('--depfile', | 51 parser.add_argument('--depfile', |
52 help='Path to the depfile. This must be specified as ' | 52 help='Path to the depfile. This must be specified as ' |
53 "the action's first output.") | 53 "the action's first output.") |
54 # We need to intercept any test runner path arguments and make all | 54 # We need to intercept any test runner path arguments and make all |
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('--isolate-file-path') | 62 group.add_argument('--isolate-file-path') |
62 group.add_argument('--output-directory') | 63 group.add_argument('--output-directory') |
63 group.add_argument('--test-apk') | 64 group.add_argument('--test-apk') |
| 65 group.add_argument('--test-apk-incremental-install-script') |
64 group.add_argument('--coverage-dir') | 66 group.add_argument('--coverage-dir') |
65 args, test_runner_args = parser.parse_known_args( | 67 args, test_runner_args = parser.parse_known_args( |
66 build_utils.ExpandFileArgs(args)) | 68 build_utils.ExpandFileArgs(args)) |
67 | 69 |
68 def RelativizePathToScript(path): | 70 def RelativizePathToScript(path): |
69 """Returns the path relative to the output script directory.""" | 71 """Returns the path relative to the output script directory.""" |
70 return os.path.relpath(path, os.path.dirname(args.script_output_path)) | 72 return os.path.relpath(path, os.path.dirname(args.script_output_path)) |
71 | 73 |
72 test_runner_path = os.path.join( | 74 test_runner_path = os.path.join( |
73 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') | 75 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') |
74 test_runner_path = RelativizePathToScript(test_runner_path) | 76 test_runner_path = RelativizePathToScript(test_runner_path) |
75 | 77 |
76 test_runner_path_args = [] | 78 test_runner_path_args = [] |
77 if args.additional_apk_list: | 79 if args.additional_apk_list: |
78 args.additional_apks.extend( | 80 args.additional_apks.extend( |
79 build_utils.ParseGypList(args.additional_apk_list)) | 81 build_utils.ParseGypList(args.additional_apk_list)) |
80 if args.additional_apks: | 82 if args.additional_apks: |
81 test_runner_path_args.extend( | 83 test_runner_path_args.extend( |
82 ('--additional-apk', RelativizePathToScript(a)) | 84 ('--additional-apk', RelativizePathToScript(a)) |
83 for a in args.additional_apks) | 85 for a in args.additional_apks) |
84 if args.apk_under_test: | 86 if args.apk_under_test: |
85 test_runner_path_args.append( | 87 test_runner_path_args.append( |
86 ('--apk-under-test', RelativizePathToScript(args.apk_under_test))) | 88 ('--apk-under-test', RelativizePathToScript(args.apk_under_test))) |
| 89 if args.apk_under_test_incremental_install_script: |
| 90 test_runner_path_args.append( |
| 91 ('--apk-under-test-incremental-install-script', |
| 92 RelativizePathToScript( |
| 93 args.apk_under_test_incremental_install_script))) |
87 if args.isolate_file_path: | 94 if args.isolate_file_path: |
88 test_runner_path_args.append( | 95 test_runner_path_args.append( |
89 ('--isolate-file-path', RelativizePathToScript(args.isolate_file_path))) | 96 ('--isolate-file-path', RelativizePathToScript(args.isolate_file_path))) |
90 if args.output_directory: | 97 if args.output_directory: |
91 test_runner_path_args.append( | 98 test_runner_path_args.append( |
92 ('--output-directory', RelativizePathToScript(args.output_directory))) | 99 ('--output-directory', RelativizePathToScript(args.output_directory))) |
93 if args.test_apk: | 100 if args.test_apk: |
94 test_runner_path_args.append( | 101 test_runner_path_args.append( |
95 ('--test-apk', RelativizePathToScript(args.test_apk))) | 102 ('--test-apk', RelativizePathToScript(args.test_apk))) |
| 103 if args.test_apk_incremental_install_script: |
| 104 test_runner_path_args.append( |
| 105 ('--test-apk-incremental-install-script', |
| 106 RelativizePathToScript(args.test_apk_incremental_install_script))) |
96 if args.coverage_dir: | 107 if args.coverage_dir: |
97 test_runner_path_args.append( | 108 test_runner_path_args.append( |
98 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) | 109 ('--coverage-dir', RelativizePathToScript(args.coverage_dir))) |
99 | 110 |
100 with open(args.script_output_path, 'w') as script: | 111 with open(args.script_output_path, 'w') as script: |
101 script.write(SCRIPT_TEMPLATE.format( | 112 script.write(SCRIPT_TEMPLATE.format( |
102 test_runner_path=str(test_runner_path), | 113 test_runner_path=str(test_runner_path), |
103 test_runner_args=str(test_runner_args), | 114 test_runner_args=str(test_runner_args), |
104 test_runner_path_args=str(test_runner_path_args))) | 115 test_runner_path_args=str(test_runner_path_args))) |
105 | 116 |
106 os.chmod(args.script_output_path, 0750) | 117 os.chmod(args.script_output_path, 0750) |
107 | 118 |
108 if args.depfile: | 119 if args.depfile: |
109 build_utils.WriteDepfile( | 120 build_utils.WriteDepfile( |
110 args.depfile, | 121 args.depfile, |
111 build_utils.GetPythonDependencies()) | 122 build_utils.GetPythonDependencies()) |
112 | 123 |
113 if __name__ == '__main__': | 124 if __name__ == '__main__': |
114 sys.exit(main(sys.argv[1:])) | 125 sys.exit(main(sys.argv[1:])) |
OLD | NEW |