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

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

Issue 1120883002: [Android] Generate scripts at build time to run android tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Renamed datadeps to data_deps to reflect recent change. Created 5 years, 6 months 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 | « breakpad/breakpad.gyp ('k') | build/android/test_runner.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #!/usr/bin/env python
2 #
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
5 # found in the LICENSE file.
6
7 """Creates a script to run an android test using build/android/test_runner.py.
8 """
9
10 import argparse
11 import os
12 import sys
13
14 from util import build_utils
15
16 SCRIPT_TEMPLATE = """\
17 #!/usr/bin/env python
18 #
19 # This file was generated by build/android/gyp/create_test_runner_script.py
20
21 import logging
22 import os
23 import sys
24
25 def main():
26 script_directory = os.path.dirname(__file__)
27
28 def ResolvePath(path):
29 \"\"\"Returns an absolute filepath given a path relative to this script.
30 \"\"\"
31 return os.path.abspath(os.path.join(script_directory, path))
32
33 test_runner_path = ResolvePath('{test_runner_path}')
34 test_runner_args = {test_runner_args}
35 test_runner_path_args = {test_runner_path_args}
36 for arg, path in test_runner_path_args.iteritems():
37 test_runner_args.extend([arg, ResolvePath(path)])
38
39 test_runner_cmd = ' '.join(
40 [test_runner_path] + test_runner_args + sys.argv[1:])
41 logging.critical(test_runner_cmd)
42 os.system(test_runner_cmd)
43
44 if __name__ == '__main__':
45 sys.exit(main())
46 """
47
48 def main():
49 parser = argparse.ArgumentParser()
50 parser.add_argument('--script-output-path',
51 help='Output path for executable script.')
52 parser.add_argument('--depfile',
53 help='Path to the depfile. This must be specified as '
54 "the action's first output.")
55 # We need to intercept any test runner path arguments and make all
56 # of the paths relative to the output script directory.
57 group = parser.add_argument_group('Test runner path arguments.')
58 group.add_argument('--output-directory')
59 group.add_argument('--isolate-file-path')
60 args, test_runner_args = parser.parse_known_args()
61
62 def RelativizePathToScript(path):
63 """Returns the path relative to the output script directory."""
64 return os.path.relpath(path, os.path.dirname(args.script_output_path))
65
66 test_runner_path = os.path.join(
67 os.path.dirname(__file__), os.path.pardir, 'test_runner.py')
68 test_runner_path = RelativizePathToScript(test_runner_path)
69
70 test_runner_path_args = {}
71 if args.output_directory:
72 test_runner_path_args['--output-directory'] = RelativizePathToScript(
73 args.output_directory)
74 if args.isolate_file_path:
75 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript(
76 args.isolate_file_path)
77
78 with open(args.script_output_path, 'w') as script:
79 script.write(SCRIPT_TEMPLATE.format(
80 test_runner_path=str(test_runner_path),
81 test_runner_args=str(test_runner_args),
82 test_runner_path_args=str(test_runner_path_args)))
83
84 os.chmod(args.script_output_path, 0750)
85
86 if args.depfile:
87 build_utils.WriteDepfile(
88 args.depfile,
89 build_utils.GetPythonDependencies())
90
91 if __name__ == '__main__':
92 sys.exit(main())
OLDNEW
« no previous file with comments | « breakpad/breakpad.gyp ('k') | build/android/test_runner.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698