Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(624)

Side by Side Diff: build/android/gyp/create_test_runner_script.py

Issue 1462363002: [Android] Make generated test scripts pass apk paths. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | build/android/gyp/write_build_config.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 26 matching lines...) Expand all
37 test_runner_args.extend([arg, ResolvePath(path)]) 37 test_runner_args.extend([arg, ResolvePath(path)])
38 38
39 test_runner_cmd = [test_runner_path] + test_runner_args + sys.argv[1:] 39 test_runner_cmd = [test_runner_path] + test_runner_args + sys.argv[1:]
40 print ' '.join(test_runner_cmd) 40 print ' '.join(test_runner_cmd)
41 return subprocess.call(test_runner_cmd) 41 return subprocess.call(test_runner_cmd)
42 42
43 if __name__ == '__main__': 43 if __name__ == '__main__':
44 sys.exit(main()) 44 sys.exit(main())
45 """ 45 """
46 46
47 def main(): 47 def main(args):
48 parser = argparse.ArgumentParser() 48 parser = argparse.ArgumentParser()
49 parser.add_argument('--script-output-path', 49 parser.add_argument('--script-output-path',
50 help='Output path for executable script.') 50 help='Output path for executable script.')
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('--output-directory') 57 group.add_argument('--output-directory')
58 group.add_argument('--isolate-file-path') 58 group.add_argument('--isolate-file-path')
59 args, test_runner_args = parser.parse_known_args() 59 group.add_argument('--apk-under-test')
60 group.add_argument('--test-apk')
61 args, test_runner_args = parser.parse_known_args(
62 build_utils.ExpandFileArgs(args))
60 63
61 def RelativizePathToScript(path): 64 def RelativizePathToScript(path):
62 """Returns the path relative to the output script directory.""" 65 """Returns the path relative to the output script directory."""
63 return os.path.relpath(path, os.path.dirname(args.script_output_path)) 66 return os.path.relpath(path, os.path.dirname(args.script_output_path))
64 67
65 test_runner_path = os.path.join( 68 test_runner_path = os.path.join(
66 os.path.dirname(__file__), os.path.pardir, 'test_runner.py') 69 os.path.dirname(__file__), os.path.pardir, 'test_runner.py')
67 test_runner_path = RelativizePathToScript(test_runner_path) 70 test_runner_path = RelativizePathToScript(test_runner_path)
68 71
69 test_runner_path_args = {} 72 test_runner_path_args = {}
70 if args.output_directory: 73 if args.output_directory:
71 test_runner_path_args['--output-directory'] = RelativizePathToScript( 74 test_runner_path_args['--output-directory'] = RelativizePathToScript(
72 args.output_directory) 75 args.output_directory)
73 if args.isolate_file_path: 76 if args.isolate_file_path:
74 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript( 77 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript(
75 args.isolate_file_path) 78 args.isolate_file_path)
79 if args.apk_under_test:
80 test_runner_path_args['--apk-under-test'] = RelativizePathToScript(
81 args.apk_under_test)
82 if args.test_apk:
83 test_runner_path_args['--test-apk'] = RelativizePathToScript(
84 args.test_apk)
76 85
77 with open(args.script_output_path, 'w') as script: 86 with open(args.script_output_path, 'w') as script:
78 script.write(SCRIPT_TEMPLATE.format( 87 script.write(SCRIPT_TEMPLATE.format(
79 test_runner_path=str(test_runner_path), 88 test_runner_path=str(test_runner_path),
80 test_runner_args=str(test_runner_args), 89 test_runner_args=str(test_runner_args),
81 test_runner_path_args=str(test_runner_path_args))) 90 test_runner_path_args=str(test_runner_path_args)))
82 91
83 os.chmod(args.script_output_path, 0750) 92 os.chmod(args.script_output_path, 0750)
84 93
85 if args.depfile: 94 if args.depfile:
86 build_utils.WriteDepfile( 95 build_utils.WriteDepfile(
87 args.depfile, 96 args.depfile,
88 build_utils.GetPythonDependencies()) 97 build_utils.GetPythonDependencies())
89 98
90 if __name__ == '__main__': 99 if __name__ == '__main__':
91 sys.exit(main()) 100 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | build/android/gyp/write_build_config.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698