Skip to content

Commit d02c521

Browse files
committed
Speed up roundtrip syntax tests
Running the unified diff is really slow, so first check if the strings are identical. Speeds up the roundtrip stdlib test by 8x on my machine.
1 parent 0e91b49 commit d02c521

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

utils/round-trip-syntax-test

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,12 @@ class RoundTripTask(object):
7676

7777
contents = ''.join(map(lambda l: l.decode('utf-8', errors='replace'),
7878
open(self.input_filename).readlines()))
79-
lines = difflib.unified_diff(contents,
80-
self.stdout.decode('utf-8',
81-
errors='replace'),
79+
stdout_contents = self.stdout.decode('utf-8', errors='replace')
80+
81+
if contents == stdout_contents:
82+
return None
83+
84+
lines = difflib.unified_diff(contents, stdout_contents,
8285
fromfile=self.input_filename,
8386
tofile='-')
8487
diff = '\n'.join(line for line in lines)

0 commit comments

Comments
 (0)