| 1 |
#!/bin/sh |
| 2 |
|
| 3 |
# This is an interdiff(1) testcase. |
| 4 |
# Test: Comprehensive test for -w option enabling patch -l behavior |
| 5 |
|
| 6 |
. ${top_srcdir-.}/tests/common.sh |
| 7 |
|
| 8 |
# Test 1: Basic functionality - whitespace differences should be ignored with -w |
| 9 |
cat << EOF > file1 |
| 10 |
line1 |
| 11 |
line2 |
| 12 |
line3 |
| 13 |
EOF |
| 14 |
|
| 15 |
cat << EOF > file2 |
| 16 |
line1 |
| 17 |
line2 modified |
| 18 |
line3 |
| 19 |
EOF |
| 20 |
|
| 21 |
cat << EOF > file3 |
| 22 |
line1 |
| 23 |
line2 modified |
| 24 |
line3 |
| 25 |
line4 |
| 26 |
EOF |
| 27 |
|
| 28 |
${DIFF} -u file1 file2 > patch1 || true |
| 29 |
${DIFF} -u file2 file3 > patch2 || true |
| 30 |
|
| 31 |
# Without -w: should show whitespace differences |
| 32 |
${INTERDIFF} patch1 patch2 > result-no-w 2>errors-no-w || exit 1 |
| 33 |
|
| 34 |
# With -w: should ignore whitespace differences and focus on content |
| 35 |
${INTERDIFF} -w patch1 patch2 > result-w 2>errors-w || exit 1 |
| 36 |
|
| 37 |
# Both should succeed, but -w version should be cleaner |
| 38 |
[ -s result-no-w ] || exit 1 |
| 39 |
[ -s result-w ] || exit 1 |
| 40 |
|
| 41 |
# The -w version should show addition of line4 |
| 42 |
grep "line4" result-w > /dev/null || exit 1 |
| 43 |
|
| 44 |
# Test 2: Regression - ensure other options still work |
| 45 |
${INTERDIFF} -b patch1 patch2 > result-b 2>errors-b || exit 1 |
| 46 |
${INTERDIFF} -B patch1 patch2 > result-B 2>errors-B || exit 1 |
| 47 |
|
| 48 |
[ -s result-b ] || exit 1 |
| 49 |
[ -s result-B ] || exit 1 |
| 50 |
|
| 51 |
exit 0 |