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

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: Define environment variable in drt-trampoline 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 print env
Mads Ager (google) 2012/11/19 09:03:30 Is this print helpful on the bots or is it left-ov
ahe 2012/11/19 09:40:39 Leftover debugging. Removed.
61
62 if out_expected_file:
63 if out_expected_file.endswith('.png'):
64 cmd.append('--notree')
65 is_png = True
66 elif not out_expected_file.endswith('.txt'):
67 raise Exception(
68 'Bad file expectation (%s) please specify either a .txt or a .png file'
69 % out_expected_file)
70
71 if options.no_timeout:
72 cmd.append('--no-timeout')
73
74 for arg in arguments:
75 if '.html' in arg:
45 test_file = arg 76 test_file = arg
46 else: 77 else:
47 cmd.append(arg) 78 cmd.append(arg)
48 79
49 if is_png: 80 if is_png:
50 # pixel tests are specified by running DRT "foo.html'-p" 81 # pixel tests are specified by running DRT "foo.html'-p"
51 cmd.append(test_file + "'-p") 82 cmd.append(test_file + "'-p")
52 else: 83 else:
53 cmd.append(test_file) 84 cmd.append(test_file)
54 85
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 print 'You can update expectations by running:\n' 139 print 'You can update expectations by running:\n'
109 print 'cp %s %s\n' % (out_file, out_expected_file) 140 print 'cp %s %s\n' % (out_file, out_expected_file)
110 print '#EOF' 141 print '#EOF'
111 142
112 if __name__ == '__main__': 143 if __name__ == '__main__':
113 try: 144 try:
114 sys.exit(main(sys.argv)) 145 sys.exit(main(sys.argv))
115 except StandardError as e: 146 except StandardError as e:
116 print 'Fail: ' + str(e) 147 print 'Fail: ' + str(e)
117 sys.exit(1) 148 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