mirror of
https://github.com/libexpat/libexpat.git
synced 2025-04-15 00:38:15 +00:00
Make xmltest.sh script work for UTF-16 builds
This commit is contained in:
parent
df75ab14f4
commit
fec399291e
2 changed files with 29 additions and 1 deletions
26
expat/tests/udiffer.py
Executable file
26
expat/tests/udiffer.py
Executable file
|
@ -0,0 +1,26 @@
|
|||
#! /usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import difflib
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
sys.exit(2)
|
||||
|
||||
try:
|
||||
with open(sys.argv[1]) as infile1:
|
||||
first = infile1.readlines()
|
||||
except UnicodeDecodeError:
|
||||
with open(sys.argv[1], encoding="utf_16") as infile1:
|
||||
first = infile1.readlines()
|
||||
try:
|
||||
with open(sys.argv[2]) as infile2:
|
||||
second = infile2.readlines()
|
||||
except UnicodeDecodeError:
|
||||
with open(sys.argv[2], encoding="utf_16") as infile2:
|
||||
second = infile2.readlines()
|
||||
|
||||
diffs = list(difflib.unified_diff(first, second,
|
||||
fromfile=sys.argv[1], tofile=sys.argv[2]))
|
||||
if diffs:
|
||||
sys.stdout.writelines(diffs)
|
||||
sys.exit(1)
|
|
@ -31,6 +31,8 @@ TS="$MYDIR"
|
|||
# OUTPUT must terminate with the directory separator.
|
||||
OUTPUT="$TS/out/"
|
||||
# OUTPUT=/home/tmp/xml-testsuite-out/
|
||||
# Unicode-aware diff utility
|
||||
DIFF="$TS/udiffer.py"
|
||||
|
||||
|
||||
# RunXmlwfNotWF file reldir
|
||||
|
@ -57,7 +59,7 @@ RunXmlwfWF() {
|
|||
read outdata < outfile
|
||||
if test "$outdata" = "" ; then
|
||||
if [ -f "out/$file" ] ; then
|
||||
diff -u "$OUTPUT$reldir$file" "out/$file" > outfile
|
||||
$DIFF "$OUTPUT$reldir$file" "out/$file" > outfile
|
||||
if [ -s outfile ] ; then
|
||||
cp outfile "$OUTPUT$reldir$file.diff"
|
||||
echo "Output differs: $reldir$file"
|
||||
|
|
Loading…
Add table
Reference in a new issue