Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: autotest.py

Issue 11039026: Use a subprocess wrapper that will throw if a command returns a non-zero result code (Closed)
Patch Set: Same thing without a custom wrapper Created July 4, 2013, 7:30 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « abp_rewrite.py ('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 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # coding: utf-8 2 # coding: utf-8
3 3
4 # This Source Code is subject to the terms of the Mozilla Public License 4 # This Source Code is subject to the terms of the Mozilla Public License
5 # version 2.0 (the "License"). You can obtain a copy of the License at 5 # version 2.0 (the "License"). You can obtain a copy of the License at
6 # http://mozilla.org/MPL/2.0/. 6 # http://mozilla.org/MPL/2.0/.
7 7
8 import sys, os, subprocess, re, difflib, utils 8 import sys, os, subprocess, re, difflib, utils
9 9
10 def run_tests(): 10 def run_tests():
(...skipping 17 matching lines...) Expand all
28 if match and match.group(1).lower() == 'name': 28 if match and match.group(1).lower() == 'name':
29 name = match.group(2) 29 name = match.group(2)
30 elif match and match.group(1).lower() == 'arguments': 30 elif match and match.group(1).lower() == 'arguments':
31 arguments = match.group(2).split(' ') 31 arguments = match.group(2).split(' ')
32 handle.close() 32 handle.close()
33 33
34 if arguments == None: 34 if arguments == None:
35 continue 35 continue
36 36
37 command = [application, os.path.join(baseDir, 'jshydra.js'), file] + argumen ts 37 command = [application, os.path.join(baseDir, 'jshydra.js'), file] + argumen ts
38 out = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.ST DOUT, env=env).communicate()[0].replace('\r', '') 38 out = subprocess.check_output(command, env=env).replace('\r', '')
39 expected = open(file + '.expected', 'r').read().replace('\r', '') 39 expected = open(file + '.expected', 'r').read().replace('\r', '')
40 if out == expected: 40 if out == expected:
41 print '%s passed' % name 41 print '%s passed' % name
42 else: 42 else:
43 print '%s failed! Log:' % name 43 print '%s failed! Log:' % name
44 for line in difflib.unified_diff(expected.split('\n'), out.split('\n'), fr omfile=file + '.expected', tofile=file + '.output'): 44 for line in difflib.unified_diff(expected.split('\n'), out.split('\n'), fr omfile=file + '.expected', tofile=file + '.output'):
45 print line 45 print line
46 print 46 print
47 47
48 if __name__ == '__main__': 48 if __name__ == '__main__':
49 run_tests() 49 run_tests()
OLDNEW
« no previous file with comments | « abp_rewrite.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld