#!/bin/sh diff_prog="../diff/diff" diff_type=unidiff verify_diff_script() { orig_left="$1" orig_right="$2" the_diff="$3" expected_diff="$4" diff_opts="$5" verify_left="verify.$orig_left" verify_right="verify.$orig_right" if [ -e "$expected_diff" ]; then echo cmp "$got_diff" "$expected_diff" if ! cmp "$got_diff" "$expected_diff" ; then echo "FAIL: $got_diff != $expected_diff" return 1 fi fi if [ -z "$diff_opts" -a "x$diff_type" = "xunidiff" ]; then cp "$orig_left" "$verify_right" patch --quiet -u "$verify_right" "$the_diff" if ! cmp "$orig_right" "$verify_right" ; then echo "FAIL: $orig_right != $verify_right" return 1 fi cp "$orig_right" "$verify_left" patch --quiet -u -R "$verify_left" "$the_diff" if ! cmp "$orig_left" "$verify_left" ; then echo "FAIL: $orig_left != $verify_left" return 1 fi elif [ -z "$diff_opts" ]; then tail -n +3 "$the_diff" | grep -v "^+" | sed 's/^.//' > "$verify_left" tail -n +3 "$the_diff" | grep -v "^-" | sed 's/^.//' > "$verify_right" if ! cmp "$orig_left" "$verify_left" ; then echo "FAIL: $orig_left != $verify_left" return 1 fi if ! cmp "$orig_right" "$verify_right" ; then echo "FAIL: $orig_right != $verify_right" return 1 fi fi echo "OK: $diff_prog $orig_left $orig_right" return 0 } for left in test*.left* ; do right="$(echo "$left" | sed 's/\.left/\.right/')" diff_opts="$(echo "$left" | sed 's/test[0-9]*\.left\([-a-zA-Z]*\).txt/\1/')" expected_diff="$(echo "$left" | sed 's/test\([-0-9a-zA-Z]*\)\..*/expect\1.diff/')" got_diff="verify.$expected_diff" "$diff_prog" $diff_opts "$left" "$right" > "$got_diff" set -e verify_diff_script "$left" "$right" "$got_diff" "$expected_diff" "$diff_opts" set +e done