Commits

Anonymous committed cdc6d4b

Test scripts to compare Tools/scripts/diff.py to GNU diff.

Comments (0)

Files changed (12)

test_diff/a.tmp

Empty file added.
+a
+b

test_diff/abcMIDdef.txt

+a
+b
+c
+M
+I
+D
+d
+e
+f

test_diff/abcdef.txt

+a
+b
+c
+d
+e
+f

test_diff/abef.txt

+a
+b
+e
+f

test_diff/bcd.txt

+b
+c
+d

test_diff/bcdef.txt

+b
+c
+d
+e
+f

test_diff/ctest.py

+import itertools
+import os
+import pprint
+import glob
+import sys
+
+verbose = False
+
+def test(f1, f2, n):
+    filt = " | egrep '^[*\-]+ .*[*\-]+$' > a.tmp"
+    cmds = [
+        "diff -C {n} {f1} {f2}" + filt,
+        sys.executable + " ~/cpython/Tools/scripts/diff.py -l {n} -c {f1} {f2}" + filt,
+    ]
+    results = []
+    for cmd in cmds:
+        cmd = cmd.format(**locals())
+        if verbose:
+            print(cmd)
+        os.system(cmd)
+        with open('a.tmp') as f:
+            result = f.read().replace('\n', '!').rstrip()
+            results.append(result)
+    print('{n}  {f1:14}  {f2:14}  {results!r}'.format(**locals()))
+    assert results[0] == results[1]
+
+
+filenames = glob.glob('*.txt')
+for f1, f2 in itertools.product(filenames, repeat=2):
+    for n in range(4):
+        test(f1, f2, n)
+e
+f

test_diff/empty.txt

Empty file added.

test_diff/qwerty.txt

+q
+w
+e
+r
+t
+y

test_diff/utest.py

+import itertools
+import os
+import pprint
+import glob
+import sys
+
+verbose = False
+
+def test(f1, f2, n):
+    cmds = [
+        "diff -U {n} {f1} {f2} | grep '@@' > a.tmp",
+        sys.executable + " ~/cpython/Tools/scripts/diff.py -l {n} -u {f1} {f2} | grep '@@' > a.tmp",
+    ]
+    results = []
+    for cmd in cmds:
+        cmd = cmd.format(**locals())
+        if verbose:
+            print(cmd)
+        os.system(cmd)
+        with open('a.tmp') as f:
+            result = f.read().rstrip()
+            results.append(result)
+    print('{n}  {f1:14}  {f2:14}  {results!r}'.format(**locals()))
+    assert results[0] == results[1]
+
+
+filenames = glob.glob('*.txt')
+for f1, f2 in itertools.product(filenames, repeat=2):
+    for n in range(4):
+        test(f1, f2, n)