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

Delta Between Two Patch Sets: autotest.py

Issue 29350244: Issue 4374 - Made Python code part of jshydra comply with our coding practices (Closed)
Left Patch Set: Merge abp_rewrite and utils module Created Aug. 28, 2016, 10:43 p.m.
Right Patch Set: Rebased and fixed typo Created Aug. 30, 2016, 12:01 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « abp_rewrite.py ('k') | tox.ini » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 # This Source Code is subject to the terms of the Mozilla Public License 1 # This Source Code is subject to the terms of the Mozilla Public License
2 # version 2.0 (the "License"). You can obtain a copy of the License at 2 # version 2.0 (the "License"). You can obtain a copy of the License at
3 # http://mozilla.org/MPL/2.0/. 3 # http://mozilla.org/MPL/2.0/.
4 4
5 from __future__ import print_function 5 from __future__ import print_function
6 6
7 import sys 7 import sys
8 import os 8 import os
9 import re 9 import re
10 import difflib 10 import difflib
(...skipping 13 matching lines...) Expand all
24 name = None 24 name = None
25 args = None 25 args = None
26 26
27 with open(filename, 'r') as file: 27 with open(filename, 'r') as file:
28 for line in file: 28 for line in file:
29 match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line) 29 match = re.search(r'^//\s*([A-Za-z]+):\s*(.*?)\s*$', line)
30 if match: 30 if match:
31 key = match.group(1).lower() 31 key = match.group(1).lower()
32 if key == 'name': 32 if key == 'name':
33 name = match.group(2) 33 name = match.group(2)
34 elif key == 'args': 34 elif key == 'arguments':
Sebastian Noack 2016/08/30 12:03:06 I accidentally replaced this string as well when r
Vasily Kuznetsov 2016/08/30 13:25:30 Oops, I missed it too. Good catch!
35 args = match.group(2).split() 35 args = match.group(2).split()
36 36
37 if args is None: 37 if args is None:
38 continue 38 continue
39 39
40 output = abp_rewrite.rewrite_js(args, filename) 40 output = abp_rewrite.rewrite_js(args, filename)
41 with open(filename + '.expected', 'rU') as file: 41 with open(filename + '.expected', 'rU') as file:
42 expected = file.read() 42 expected = file.read()
43 43
44 if output == expected: 44 if output == expected:
45 print(name + ' passed') 45 print(name + ' passed')
46 else: 46 else:
47 succeed = False 47 succeed = False
48 print(name + ' failed! Log:') 48 print(name + ' failed! Log:')
49 for line in difflib.unified_diff(expected.splitlines(), 49 for line in difflib.unified_diff(expected.splitlines(),
50 output.splitlines(), 50 output.splitlines(),
51 fromfile=filename + '.expected', 51 fromfile=filename + '.expected',
52 tofile=filename + '.output'): 52 tofile=filename + '.output'):
53 print(line) 53 print(line)
54 print() 54 print()
55 55
56 return succeed 56 return succeed
57 57
58 if __name__ == '__main__': 58 if __name__ == '__main__':
59 sys.exit(not run_tests()) 59 sys.exit(not run_tests())
LEFTRIGHT

Powered by Google App Engine
This is Rietveld