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

Side by Side Diff: dart/tools/testing/drt-trampoline.py

Issue 11359187: Allow tests to specify a package root. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address review comments Created 8 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 | Annotate | Revision Log
« no previous file with comments | « dart/tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 # Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 # for details. All rights reserved. Use of this source code is governed by a 2 # for details. All rights reserved. Use of this source code is governed by a
3 # BSD-style license that can be found in the LICENSE file. 3 # BSD-style license that can be found in the LICENSE file.
4 # 4 #
5 # For now we have to use this trampoline to turn --dart-flags command line 5 # For now we have to use this trampoline to turn --dart-flags command line
6 # switch into env variable DART_FLAGS. Eventually, DumpRenderTree should 6 # switch into env variable DART_FLAGS. Eventually, DumpRenderTree should
7 # support --dart-flags and this hack may go away. 7 # support --dart-flags and this hack may go away.
8 # 8 #
9 # Expected invocation: python drt-trampoline.py <path to DRT> <DRT command line> 9 # Expected invocation: python drt-trampoline.py <path to DRT> <DRT command line>
10 10
11 import optparse
11 import os 12 import os
12 import signal 13 import signal
13 import subprocess 14 import subprocess
14 import sys 15 import sys
15 16
16 DART_FLAGS_PREFIX = '--dart-flags=' 17 def parse_options(argv):
17 OUT_EXPECTATION_PREFIX = '--out-expectation=' 18 parser = optparse.OptionParser()
19 parser.add_option('--dart-flags',
20 metavar='FLAGS',
21 dest='dart_flags')
22 parser.add_option('--out-expectation',
23 metavar='FILE',
24 dest='out_expected_file')
25 parser.add_option('--package-root',
26 metavar='DIRECTORY',
27 dest='dart_package_root')
28 parser.add_option('--no-timeout',
29 action='store_true')
30 return parser.parse_args(args=argv)
31
18 32
19 def main(argv): 33 def main(argv):
20 drt_path = argv[1] 34 drt_path = argv[1]
21 command_line = argv[2:] 35 (options, arguments) = parse_options(argv[2:])
22 36
23 cmd = [drt_path] 37 cmd = [drt_path]
24 38
25 env = None 39 env = None
26 test_file = None 40 test_file = None
27 out_expected_file = None 41 dart_flags = options.dart_flags
42 out_expected_file = options.out_expected_file
43 dart_package_root = options.dart_package_root
28 is_png = False 44 is_png = False
29 45
30 # parse arguments, filtering out flags, and selecting the input test file 46 if dart_flags:
31 for arg in command_line: 47 if not env:
32 if arg.startswith(DART_FLAGS_PREFIX):
33 env = dict(os.environ.items()) 48 env = dict(os.environ.items())
34 env['DART_FLAGS'] = arg[len(DART_FLAGS_PREFIX):] 49 env['DART_FLAGS'] = dart_flags
35 elif arg.startswith(OUT_EXPECTATION_PREFIX): 50
36 out_expected_file = arg[len(OUT_EXPECTATION_PREFIX):] 51 if dart_package_root:
37 if out_expected_file.endswith('.png'): 52 if not env:
38 cmd.append('--notree') 53 env = dict(os.environ.items())
39 is_png = True 54 absolute_path = os.path.abspath(dart_package_root)
40 elif not out_expected_file.endswith('.txt'): 55 absolute_path = absolute_path.replace(os.path.sep, '/')
41 raise Exception( 56 if not absolute_path.startswith('/'):
42 'Bad file expectation (%s), ' % out_expected_file 57 # Happens on Windows for C:\packages
43 + 'please specify either a .txt or a .png file') 58 absolute_path = '/%s' % absolute_path
44 elif '.html' in arg: 59 env['DART_PACKAGE_ROOT'] = 'file://%s' % absolute_path
60
61 if out_expected_file:
62 if out_expected_file.endswith('.png'):
63 cmd.append('--notree')
64 is_png = True
65 elif not out_expected_file.endswith('.txt'):
66 raise Exception(
67 'Bad file expectation (%s) please specify either a .txt or a .png file'
68 % out_expected_file)
69
70 if options.no_timeout:
71 cmd.append('--no-timeout')
72
73 for arg in arguments:
74 if '.html' in arg:
45 test_file = arg 75 test_file = arg
46 else: 76 else:
47 cmd.append(arg) 77 cmd.append(arg)
48 78
49 if is_png: 79 if is_png:
50 # pixel tests are specified by running DRT "foo.html'-p" 80 # pixel tests are specified by running DRT "foo.html'-p"
51 cmd.append(test_file + "'-p") 81 cmd.append(test_file + "'-p")
52 else: 82 else:
53 cmd.append(test_file) 83 cmd.append(test_file)
54 84
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 print 'You can update expectations by running:\n' 138 print 'You can update expectations by running:\n'
109 print 'cp %s %s\n' % (out_file, out_expected_file) 139 print 'cp %s %s\n' % (out_file, out_expected_file)
110 print '#EOF' 140 print '#EOF'
111 141
112 if __name__ == '__main__': 142 if __name__ == '__main__':
113 try: 143 try:
114 sys.exit(main(sys.argv)) 144 sys.exit(main(sys.argv))
115 except StandardError as e: 145 except StandardError as e:
116 print 'Fail: ' + str(e) 146 print 'Fail: ' + str(e)
117 sys.exit(1) 147 sys.exit(1)
OLDNEW
« no previous file with comments | « dart/tools/testing/dart/test_suite.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698