Skip to content

Commit 426c596

Browse files
authored
Merge pull request swiftlang#21005 from compnerd/diff-less
2 parents da8ff3a + 2793b64 commit 426c596

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

utils/incrparse/validate_parse.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@
44

55
import argparse
66
import os
7-
import subprocess
87
import sys
98

10-
from test_util import TestFailedError, run_command, \
11-
serializeIncrParseMarkupFile
9+
from test_util import TestFailedError, serializeIncrParseMarkupFile
1210

1311

1412
def main():
@@ -102,19 +100,18 @@ def main():
102100
sys.exit(1)
103101

104102
# Check if the two syntax trees are the same
105-
try:
106-
run_command(
107-
[
108-
'diff', '-u',
109-
incremental_serialized_file,
110-
post_edit_serialized_file
111-
])
112-
except subprocess.CalledProcessError as e:
103+
import difflib
104+
lines = difflib.unified_diff(open(incremental_serialized_file).readlines(),
105+
open(post_edit_serialized_file).readlines(),
106+
fromfile=incremental_serialized_file,
107+
tofile=incremental_serialized_file)
108+
diff = '\n'.join(line for line in lines)
109+
if diff:
113110
print('Test case "%s" of %s FAILed' % (test_case, test_file),
114111
file=sys.stderr)
115112
print('Syntax tree of incremental parsing does not match '
116113
'from-scratch parsing of post-edit file:\n\n', file=sys.stderr)
117-
print(e.output, file=sys.stderr)
114+
print(diff, file=sys.stderr)
118115
sys.exit(1)
119116

120117

0 commit comments

Comments
 (0)