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

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

Issue 2101243005: Add a snapshot of flutter/engine/src/build to our sdk (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: add README.dart Created 4 years, 5 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 | « build/android/gyp/create_standalone_apk.py ('k') | build/android/gyp/dex.py » ('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 group.add_argument('--support-apk')
61 args, test_runner_args = parser.parse_known_args()
62
63 def RelativizePathToScript(path):
64 """Returns the path relative to the output script directory."""
65 return os.path.relpath(path, os.path.dirname(args.script_output_path))
66
67 test_runner_path = os.path.join(
68 os.path.dirname(__file__), os.path.pardir, 'test_runner.py')
69 test_runner_path = RelativizePathToScript(test_runner_path)
70
71 test_runner_path_args = {}
72 if args.output_directory:
73 test_runner_path_args['--output-directory'] = RelativizePathToScript(
74 args.output_directory)
75 if args.isolate_file_path:
76 test_runner_path_args['--isolate-file-path'] = RelativizePathToScript(
77 args.isolate_file_path)
78 if args.support_apk:
79 test_runner_path_args['--support-apk'] = RelativizePathToScript(
80 args.support_apk)
81
82 with open(args.script_output_path, 'w') as script:
83 script.write(SCRIPT_TEMPLATE.format(
84 test_runner_path=str(test_runner_path),
85 test_runner_args=str(test_runner_args),
86 test_runner_path_args=str(test_runner_path_args)))
87
88 os.chmod(args.script_output_path, 0750)
89
90 if args.depfile:
91 build_utils.WriteDepfile(
92 args.depfile,
93 build_utils.GetPythonDependencies())
94
95 if __name__ == '__main__':
96 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/gyp/create_standalone_apk.py ('k') | build/android/gyp/dex.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698