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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 parser.add_argument('--script-output-path', | 50 parser.add_argument('--script-output-path', |
51 help='Output path for executable script.') | 51 help='Output path for executable script.') |
52 parser.add_argument('--depfile', | 52 parser.add_argument('--depfile', |
53 help='Path to the depfile. This must be specified as ' | 53 help='Path to the depfile. This must be specified as ' |
54 "the action's first output.") | 54 "the action's first output.") |
55 # We need to intercept any test runner path arguments and make all | 55 # We need to intercept any test runner path arguments and make all |
56 # of the paths relative to the output script directory. | 56 # of the paths relative to the output script directory. |
57 group = parser.add_argument_group('Test runner path arguments.') | 57 group = parser.add_argument_group('Test runner path arguments.') |
58 group.add_argument('--output-directory') | 58 group.add_argument('--output-directory') |
59 group.add_argument('--isolate-file-path') | 59 group.add_argument('--isolate-file-path') |
60 group.add_argument('--support-apk') | |
61 args, test_runner_args = parser.parse_known_args() | 60 args, test_runner_args = parser.parse_known_args() |
62 | 61 |
63 def RelativizePathToScript(path): | 62 def RelativizePathToScript(path): |
64 """Returns the path relative to the output script directory.""" | 63 """Returns the path relative to the output script directory.""" |
65 return os.path.relpath(path, os.path.dirname(args.script_output_path)) | 64 return os.path.relpath(path, os.path.dirname(args.script_output_path)) |
66 | 65 |
67 test_runner_path = os.path.join( | 66 test_runner_path = os.path.join( |
68 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') | 67 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') |
69 test_runner_path = RelativizePathToScript(test_runner_path) | 68 test_runner_path = RelativizePathToScript(test_runner_path) |
70 | 69 |
71 test_runner_path_args = {} | 70 test_runner_path_args = {} |
72 if args.output_directory: | 71 if args.output_directory: |
73 test_runner_path_args['--output-directory'] = RelativizePathToScript( | 72 test_runner_path_args['--output-directory'] = RelativizePathToScript( |
74 args.output_directory) | 73 args.output_directory) |
75 if args.isolate_file_path: | 74 if args.isolate_file_path: |
76 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript( | 75 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript( |
77 args.isolate_file_path) | 76 args.isolate_file_path) |
78 if args.support_apk: | |
79 test_runner_path_args['--support-apk'] = RelativizePathToScript( | |
80 args.support_apk) | |
81 | 77 |
82 with open(args.script_output_path, 'w') as script: | 78 with open(args.script_output_path, 'w') as script: |
83 script.write(SCRIPT_TEMPLATE.format( | 79 script.write(SCRIPT_TEMPLATE.format( |
84 test_runner_path=str(test_runner_path), | 80 test_runner_path=str(test_runner_path), |
85 test_runner_args=str(test_runner_args), | 81 test_runner_args=str(test_runner_args), |
86 test_runner_path_args=str(test_runner_path_args))) | 82 test_runner_path_args=str(test_runner_path_args))) |
87 | 83 |
88 os.chmod(args.script_output_path, 0750) | 84 os.chmod(args.script_output_path, 0750) |
89 | 85 |
90 if args.depfile: | 86 if args.depfile: |
91 build_utils.WriteDepfile( | 87 build_utils.WriteDepfile( |
92 args.depfile, | 88 args.depfile, |
93 build_utils.GetPythonDependencies()) | 89 build_utils.GetPythonDependencies()) |
94 | 90 |
95 if __name__ == '__main__': | 91 if __name__ == '__main__': |
96 sys.exit(main()) | 92 sys.exit(main()) |
OLD | NEW |