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

Side by Side Diff: tools/testing/frogpad/frogpad.py

Issue 9663024: now use xvfb (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 2
3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 3 # Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
4 # for details. All rights reserved. Use of this source code is governed by a 4 # for details. All rights reserved. Use of this source code is governed by a
5 # BSD-style license that can be found in the LICENSE file. 5 # BSD-style license that can be found in the LICENSE file.
6 # 6 #
7 7
8 """ 8 """
9 Frogpad is used to compile .dart files to javascript. 9 Frogpad is used to compile .dart files to javascript.
10 10
(...skipping 13 matching lines...) Expand all
24 and the dart program is compiled to javascript. The generated javascript is 24 and the dart program is compiled to javascript. The generated javascript is
25 placed in a <pre> element with id "output". 25 placed in a <pre> element with id "output".
26 26
27 When the html page is passed to DumpRenderTree, the dumped output will 27 When the html page is passed to DumpRenderTree, the dumped output will
28 have the generated javascript. 28 have the generated javascript.
29 """ 29 """
30 30
31 import logging 31 import logging
32 import optparse 32 import optparse
33 import os.path 33 import os.path
34 import platform
34 import re 35 import re
35 import subprocess 36 import subprocess
36 import sys 37 import sys
37 38
38 39
39 class FileNotFoundException(Exception): 40 class FileNotFoundException(Exception):
40 def __init__(self, file_name): 41 def __init__(self, file_name):
41 self._name = file_name 42 self._name = file_name
42 43
43 def __str__(self): 44 def __str__(self):
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
163 self.dart_dir = os.path.dirname(os.path.dirname(os.path.dirname( 164 self.dart_dir = os.path.dirname(os.path.dirname(os.path.dirname(
164 self.frogpad_dir))) 165 self.frogpad_dir)))
165 166
166 # directory of frog compiler source code 167 # directory of frog compiler source code
167 self.frog_dir = os.path.join(self.dart_dir, "frog") 168 self.frog_dir = os.path.join(self.dart_dir, "frog")
168 169
169 logging.debug("dartdir_dir: '%s'" % self.dart_dir) 170 logging.debug("dartdir_dir: '%s'" % self.dart_dir)
170 logging.debug("frog_dir: '%s'" % self.frog_dir) 171 logging.debug("frog_dir: '%s'" % self.frog_dir)
171 logging.debug("frogpad_dir: '%s'" % self.frogpad_dir) 172 logging.debug("frogpad_dir: '%s'" % self.frogpad_dir)
172 173
173 logging.info("cwd '%s'" % os.getcwd())
174
175 # location of frogpad.js 174 # location of frogpad.js
176 if not options.frogpad_js: 175 if not options.frogpad_js:
177 raise Exception("--frogpad_js is required") 176 raise Exception("--frogpad_js is required")
178 177
179 if not os.path.exists(options.frogpad_js): 178 if not os.path.exists(options.frogpad_js):
180 raise FileNotFoundException(options.frogpad_js) 179 raise FileNotFoundException(options.frogpad_js)
181 180
182 self.frogpad_js = options.frogpad_js 181 self.frogpad_js = options.frogpad_js
183 182
184 if options.out: 183 if options.out:
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 tags = [] 221 tags = []
223 for f in self.id_to_file.values(): 222 for f in self.id_to_file.values():
224 tags.append(self._create_tag(f.id, f.contents)) 223 tags.append(self._create_tag(f.id, f.contents))
225 tags.append(self._create_tag(MAIN_ID, self.main_file)) 224 tags.append(self._create_tag(MAIN_ID, self.main_file))
226 html = HTML.replace("{{script_tags}}", "".join(tags)) 225 html = HTML.replace("{{script_tags}}", "".join(tags))
227 html = html.replace("{{FROGPAD_JS}}", read_file(self.frogpad_js)) 226 html = html.replace("{{FROGPAD_JS}}", read_file(self.frogpad_js))
228 return html 227 return html
229 228
230 def generate_js(self): 229 def generate_js(self):
231 drt = os.path.join(self.dart_dir, "client/tests/drt/DumpRenderTree") 230 drt = os.path.join(self.dart_dir, "client/tests/drt/DumpRenderTree")
231 if platform.system() == 'Darwin':
232 drt += ".app"
233 elif platform.system() == 'Windows':
234 raise Exception("frogpad does not run on Windows")
235
232 check_exists(drt) 236 check_exists(drt)
233 args = [] 237 args = []
234 args.append(drt) 238 args.append(drt)
235 args.append(self.html_file) 239 args.append(self.html_file)
236 240
237 stdout = run_command(args) 241 stdout = run_command(args)
238 match = OUTPUT_JAVASCRIPT_REGEX.match(stdout) 242 match = OUTPUT_JAVASCRIPT_REGEX.match(stdout)
239 if not match: 243 if not match:
240 raise Exception("can't find regex in DumpRenderTree output") 244 raise Exception("can't find regex in DumpRenderTree output")
241 return match.group(1) 245 return match.group(1)
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
333 337
334 def run_command(args): 338 def run_command(args):
335 """ 339 """
336 Args: 340 Args:
337 command: comamnd with arguments to exec 341 command: comamnd with arguments to exec
338 Returns: 342 Returns:
339 all output that this command sent to stdout 343 all output that this command sent to stdout
340 """ 344 """
341 345
342 command = format_command(args) 346 command = format_command(args)
343 logging.debug("RUNNING " + command) 347 logging.info("RUNNING: '%s'" % command)
344 child = subprocess.Popen(args, 348 child = subprocess.Popen(args,
345 stdout=subprocess.PIPE, 349 stdout=subprocess.PIPE,
346 stderr=subprocess.PIPE, 350 stderr=subprocess.PIPE,
347 close_fds=True) 351 close_fds=True)
348 (stdout, stderr) = child.communicate() 352 (stdout, stderr) = child.communicate()
349 exit_code = child.wait() 353 exit_code = child.wait()
350 if exit_code: 354 if exit_code:
351 for line in stderr.splitlines(): 355 for line in stderr.splitlines():
352 logging.info(line) 356 logging.info(line)
353 msg = "FAILURE (exit_code=%d): '%s'" % (exit_code, command) 357 msg = "FAILURE (exit_code=%d): '%s'" % (exit_code, command)
354 logging.error(msg) 358 logging.error(msg)
355 raise CommandFailedException(msg) 359 raise CommandFailedException(msg)
356 logging.debug("SUCCEEDED (%d bytes)" % len(stdout)) 360 logging.debug("SUCCEEDED (%d bytes)" % len(stdout))
357 return stdout 361 return stdout
358 362
359 363
360 def main(argv): 364 def main(argv):
361 Pad(argv) 365 Pad(argv)
362 366
363 if __name__ == "__main__": 367 if __name__ == "__main__":
364 sys.exit(main(sys.argv)) 368 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698