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

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

Issue 10701025: fixing drt-trampoline (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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 | Annotate | Revision Log
« tests/html/html.status ('K') | « tests/utils/png_layout_test.png ('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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 'Bad file expectation (%s), ' % out_expected_file 42 'Bad file expectation (%s), ' % out_expected_file
43 + 'please specify either a .txt or a .png file') 43 + 'please specify either a .txt or a .png file')
44 elif arg.endswith('.html'): 44 elif arg.endswith('.html'):
45 test_file = arg 45 test_file = arg
46 cmd.append(arg) 46 cmd.append(arg)
47 else: 47 else:
48 cmd.append(arg) 48 cmd.append(arg)
49 49
50 50
51 p = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE) 51 p = subprocess.Popen(cmd, env=env, stdout=subprocess.PIPE)
52 p.wait() 52 output, error = p.communicate()
Siggi Cherem (dart-lang) 2012/06/28 21:23:57 I believe the issue is related to pipeing output a
Emily Fortuna 2012/06/28 21:44:39 I think you're right. I seem to remember reading i
53 if p.returncode != 0: 53 if p.returncode != 0:
54 raise Exception('Failed to run command. return code=%s' % p.returncode) 54 raise Exception('Failed to run command. return code=%s' % p.returncode)
55 55
56 if out_expected_file: 56 if out_expected_file:
57 # Compare output to the given expectation file. 57 # Compare output to the given expectation file.
58 output = None
59 expectation = None 58 expectation = None
60 with p.stdout as res: 59 if is_png:
61 if is_png: 60 # DRT prints the image to STDOUT, but includes extra text that we trim:
62 # DRT prints the image to STDOUT, but includes 5 header lines. 61 # - 5 header lines
63 for i in range(4): res.readline() 62 # - a '#EOF\n' at the end
64 output = res.read() 63 output = output.replace('\n', '_', 3)
64 output = output[output.find('\n') + 1: -5]
Emily Fortuna 2012/06/28 21:44:39 Perhaps I'm misunderstanding how this code works,
Siggi Cherem (dart-lang) 2012/06/28 21:55:06 Done. Turns out that it was 4 header lines, not 5.
65 if os.path.exists(out_expected_file): 65 if os.path.exists(out_expected_file):
66 with open(out_expected_file, 'r') as f: 66 with open(out_expected_file, 'r') as f:
67 expectation = f.read() 67 expectation = f.read()
68 else: 68 else:
69 # Instructions on how to create the expectation will be printed below 69 # Instructions on how to create the expectation will be printed below
70 # (outout != expectation) 70 # (outout != expectation)
71 print 'File %s was not found' % out_expected_file 71 print 'File %s was not found' % out_expected_file
72 expectation = None 72 expectation = None
73 73
74 # Report test status using the format test.dart expects to see from DRT. 74 # Report test status using the format test.dart expects to see from DRT.
75 print 'Content-Type: text/plain' 75 print 'Content-Type: text/plain'
76 if expectation == output: 76 if expectation == output:
77 print 'PASS' 77 print 'PASS'
78 print 'Expectation matches' 78 print 'Expectation matches'
79 else: 79 else:
80 # Generate a temporary file in the same place as the .html file: 80 # Generate a temporary file in the same place as the .html file:
81 out_file = test_file[:test_file.rfind('.html')] + out_expected_file[-4:] 81 out_file = test_file[:test_file.rfind('.html')] + out_expected_file[-4:]
82 with open(out_file, 'w') as f: 82 with open(out_file, 'w') as f:
83 f.write(output) 83 f.write(output)
84 print 'FAIL' 84 print 'FAIL'
85 print 'Expectation didn\'t match. Update expectations by running:\n' 85 print 'Expectation didn\'t match. Update expectations by running:\n'
86 print 'cp %s %s\n' % (out_file, out_expected_file) 86 print 'cp %s %s\n' % (out_file, out_expected_file)
87 print '#EOF' 87 print '#EOF'
88 else: 88 else:
89 # Pipe through the output for non-layout tests. 89 # Pipe through the output for non-layout tests.
90 sys.stdout.write(p.stdout.read()) 90 print output
91 91
92 if __name__ == '__main__': 92 if __name__ == '__main__':
93 try: 93 try:
94 sys.exit(main(sys.argv)) 94 sys.exit(main(sys.argv))
95 except StandardError as e: 95 except StandardError as e:
96 print 'Fail: ' + str(e) 96 print 'Fail: ' + str(e)
97 sys.exit(1) 97 sys.exit(1)
OLDNEW
« tests/html/html.status ('K') | « tests/utils/png_layout_test.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698