|
Iain Douglas |
342623 |
#!/bin/bash
|
|
Iain Douglas |
342623 |
# Author: Iain Douglas <centos@1n6.org.uk>
|
|
Iain Douglas |
342623 |
|
|
Iain Douglas |
342623 |
# Tests for diff
|
|
Iain Douglas |
342623 |
|
|
Iain Douglas |
342623 |
# Basic Tests
|
|
Iain Douglas |
342623 |
|
|
Athmane Madjoudj |
536354 |
ExitFail() {
|
|
Athmane Madjoudj |
536354 |
t_Log "FAIL"
|
|
Athmane Madjoudj |
536354 |
exit $FAIL
|
|
Athmane Madjoudj |
536354 |
}
|
|
Athmane Madjoudj |
536354 |
|
|
Iain Douglas |
342623 |
t_Log "Running $0 - diff tests"
|
|
Iain Douglas |
342623 |
|
|
Iain Douglas |
342623 |
diff -v &>/dev/null
|
|
Iain Douglas |
342623 |
|
|
Iain Douglas |
342623 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
F1=/var/tmp/testf1.txt
|
|
Athmane Madjoudj |
536354 |
F2=/var/tmp/testf2.txt
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Most of the following tests are taken from the examples in the info
|
|
Athmane Madjoudj |
536354 |
# documentation for diffutils.
|
|
Athmane Madjoudj |
536354 |
#
|
|
Athmane Madjoudj |
536354 |
# Create a couple of files to work with. We'll use sed to make changes as we
|
|
Athmane Madjoudj |
536354 |
# go.
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
TEXT="Here lyeth muche rychnesse in lytell space. -- John Heywood"
|
|
Athmane Madjoudj |
536354 |
echo $TEXT >$F1
|
|
Athmane Madjoudj |
536354 |
cp $F1 $F2
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Start by checking the options that determine how whitespace and case are
|
|
Athmane Madjoudj |
536354 |
# handled -E -b -w -B -i -I -q and their long form variants
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Baseline check to ensure diff sees the files are the same.
|
|
Athmane Madjoudj |
536354 |
echo "Check files are the same"
|
|
Athmane Madjoudj |
536354 |
diff $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Convert a <space> to <space><tab> in F2 then check that diff sees the change
|
|
Athmane Madjoudj |
536354 |
# as it should.
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
sed -i 's/ / \t/' $F2
|
|
Athmane Madjoudj |
536354 |
echo "Check different files"
|
|
Athmane Madjoudj |
536354 |
diff $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Convert the first space in $F1 to 4 spaces and check that -E and
|
|
Athmane Madjoudj |
536354 |
# --ignore-tab-expansion works and sees no difference between the
|
|
Athmane Madjoudj |
536354 |
# two files.
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -E"
|
|
Athmane Madjoudj |
536354 |
sed -i 's/ / /' $F1
|
|
Athmane Madjoudj |
536354 |
diff -E $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --ignore-tab-expansion"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-tab-expansion $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# reduce the 4 spaces to 3 and check diff -E sees a difference
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -E sees a difference in whitespace"
|
|
Athmane Madjoudj |
536354 |
sed -i 's/ / /' $F1
|
|
Athmane Madjoudj |
536354 |
diff -E $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -b --ignore-space-change add some spaces to the end of the line
|
|
Athmane Madjoudj |
536354 |
# to make sure.
|
|
Athmane Madjoudj |
536354 |
sed -i 's/$/ /' $F1
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -b"
|
|
Athmane Madjoudj |
536354 |
diff -b $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --ignore-space-change"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-space-change $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# The -b option ignotes difference in whitespace where it already exists.
|
|
Athmane Madjoudj |
536354 |
# Check that whitespace added in $F1 where non exists in $F2 is caught by
|
|
Athmane Madjoudj |
536354 |
# -b
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -b sees whitespace where non exists"
|
|
Athmane Madjoudj |
536354 |
sed -i 's/ss/s s/' $F1
|
|
Athmane Madjoudj |
536354 |
diff -b $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -w --ignore-all-space
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -w"
|
|
Athmane Madjoudj |
536354 |
diff -w $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --ignore-all-space"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-all-space $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -B --ignore blank lines, create some new files to work with first.
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo $TEXT>$F1
|
|
Athmane Madjoudj |
536354 |
echo $TEXT>>$F1
|
|
Athmane Madjoudj |
536354 |
echo $TEXT>$F2
|
|
Athmane Madjoudj |
536354 |
echo "" >>$F2
|
|
Athmane Madjoudj |
536354 |
echo $TEXT>>$F2
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check that diff sees the new test files are different.
|
|
Athmane Madjoudj |
536354 |
echo "-B --ignore blank lines, pre check files are different"
|
|
Athmane Madjoudj |
536354 |
diff $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -B"
|
|
Athmane Madjoudj |
536354 |
diff -B $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --ignore-blank-lines"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-blank-lines $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -i --ignore-case, first ensure that diff sees a difference in case,
|
|
Athmane Madjoudj |
536354 |
# as we're using the files from the earlier test we need to use the -B option
|
|
Athmane Madjoudj |
536354 |
# too.
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check test file is different"
|
|
Athmane Madjoudj |
536354 |
sed -i 's/l/L/g' $F1
|
|
Athmane Madjoudj |
536354 |
diff -B $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check that -i causes diff to ignore the difference in case.
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -i"
|
|
Athmane Madjoudj |
536354 |
diff -B -i $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --ignore-case"
|
|
Athmane Madjoudj |
536354 |
diff -B --ignore-case $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -I --ignore-matching-lines=regexp
|
|
Athmane Madjoudj |
536354 |
echo $TEXT >$F1
|
|
Athmane Madjoudj |
536354 |
echo "1"$TEXT"1" >>$F1
|
|
Athmane Madjoudj |
536354 |
echo "1"$TEXT >$F2
|
|
Athmane Madjoudj |
536354 |
echo $TEXT >>$F2
|
|
Athmane Madjoudj |
536354 |
echo "Check test files are different"
|
|
Athmane Madjoudj |
536354 |
diff $F1 $F2 &>/dev/null && ExitFail
|
|
Athmane Madjoudj |
536354 |
t_Log "PASS"
|
|
Athmane Madjoudj |
536354 |
echo "Check -I"
|
|
Athmane Madjoudj |
536354 |
diff -I '^[[:digit:]]' $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check --ignore-matching-lines=regexp"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-matching-lines='^[[:digit:]]' $F1 $F2
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -q --brief
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -q"
|
|
Athmane Madjoudj |
536354 |
diff -q $F1 $F2 | grep -q "Files /var/tmp/testf1.txt and /var/tmp/testf2.txt differ"
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "diff --brief"
|
|
Athmane Madjoudj |
536354 |
diff --brief $F1 $F2 | grep -q "Files /var/tmp/testf1.txt and /var/tmp/testf2.txt differ"
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check output formats are correct, again the examples from the info docs are
|
|
Athmane Madjoudj |
536354 |
# used in the tests as are the lao and tzu texts. As we've previously testes
|
|
Athmane Madjoudj |
536354 |
# cmp it should be safe to use to compare the generated output against known
|
|
Athmane Madjoudj |
536354 |
# correct output.
|
|
Athmane Madjoudj |
536354 |
#
|
|
Athmane Madjoudj |
536354 |
# start with normal format
|
|
Athmane Madjoudj |
536354 |
echo "Check diff output formats"
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
DIR=./tests/p_diffutils
|
|
Athmane Madjoudj |
536354 |
FILES="$DIR"/files
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check normal output format"
|
|
Athmane Madjoudj |
536354 |
diff "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/normal_format -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check contxt format - note that this outputs time information that we will
|
|
Athmane Madjoudj |
536354 |
# ignore by skipping the first 3 lines
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo Check default context format -c
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
diff -c "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/context_format -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check contect format with only 1 line
|
|
Athmane Madjoudj |
536354 |
echo "Check context format with Less Context -C 1"
|
|
Athmane Madjoudj |
536354 |
diff -C 1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/context_format-1 -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check unified format again there are timestams which we will ignore
|
|
Athmane Madjoudj |
536354 |
echo "Check unified format "
|
|
Athmane Madjoudj |
536354 |
diff -u "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check unified shortend format -U lines and the long form option
|
|
Athmane Madjoudj |
536354 |
# --unified=lines, in both cases we'll use 1 for lines.
|
|
Athmane Madjoudj |
536354 |
echo "Check unified output with less context -U 1"
|
|
Athmane Madjoudj |
536354 |
diff -U 1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format-1 -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check unified output with less context --unified=1"
|
|
Athmane Madjoudj |
536354 |
diff --unified=1 "$FILES"/lao "$FILES"/tzu | tail -n +3 | cmp "$FILES"/unified_format-1 -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check we can change the labels
|
|
Athmane Madjoudj |
536354 |
echo "Check the --label option"
|
|
Athmane Madjoudj |
536354 |
diff -C 2 --label=original --label=modified "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/label-change
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check side-by-side output width = 72
|
|
Athmane Madjoudj |
536354 |
echo "Check side-by-side" output -y -W 72
|
|
Athmane Madjoudj |
536354 |
diff -t -y -W 72 "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/side-by-side-W72 -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check side-by-side with left column suppression
|
|
Athmane Madjoudj |
536354 |
echo "Check left column suppression in side-by-side output"
|
|
Christoph Galuschka |
78f125 |
diff --width=72 -y --left-column "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/left_column
|
|
Christoph Galuschka |
78f125 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check side-by-side with common line suppression
|
|
Athmane Madjoudj |
536354 |
echo "Check left column suppression in side-by-side output"
|
|
Athmane Madjoudj |
536354 |
diff --width=72 -y --suppress-common-lines "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/supress_common_lines -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check an ed script is correctly generated
|
|
Athmane Madjoudj |
536354 |
echo "Check an ed script is correctly generated diff -e"
|
|
Athmane Madjoudj |
536354 |
diff -e "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check diff -f --forward-ed works
|
|
Athmane Madjoudj |
536354 |
echo "Check that a forward ed script is generated -f "
|
|
Athmane Madjoudj |
536354 |
diff -f "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script-f -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check that a forward ed script is generated --forward-ed "
|
|
Athmane Madjoudj |
536354 |
diff --forward-ed "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/ed_script-f -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check RCS script generation -n --rcs
|
|
Athmane Madjoudj |
536354 |
echo "Check RCS scripts are generated -n"
|
|
Athmane Madjoudj |
536354 |
diff -n "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/rcs_script -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
echo "Check RCS scripts are generated --rcs"
|
|
Athmane Madjoudj |
536354 |
diff --rcs "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/rcs_script -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check if-then-else output diff -D --ifdef
|
|
Athmane Madjoudj |
536354 |
echo "Check -D output"
|
|
Athmane Madjoudj |
536354 |
diff -DTWO "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/if_then_else -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check --ifdef output"
|
|
Athmane Madjoudj |
536354 |
diff --ifdef=TWO "$FILES"/lao "$FILES"/tzu | cmp "$FILES"/if_then_else -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check Incomplete last line (no \n)
|
|
Athmane Madjoudj |
536354 |
echo "Checking incomplete last line - normal"
|
|
Athmane Madjoudj |
536354 |
diff "$FILES"/F "$FILES"/G | cmp "$FILES"/F-G -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Checking incomplete last line -n"
|
|
Athmane Madjoudj |
536354 |
diff -n "$FILES"/F "$FILES"/G | cmp "$FILES"/n_F-G -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Checking incomplete last line -e"
|
|
Athmane Madjoudj |
536354 |
diff -e "$FILES"/F "$FILES"/G 2>&1 | cmp "$FILES"/e_F-G
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check diff output to -l --paginate, the header is variable so skip over it
|
|
Athmane Madjoudj |
536354 |
echo "Check diff output to pager -l"
|
|
Athmane Madjoudj |
536354 |
diff -l "$FILES"/lao "$FILES"/tzu |tail -n +4 | cmp "$FILES"/paginate -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check diff output to pager -l"
|
|
Athmane Madjoudj |
536354 |
diff -l "$FILES"/lao "$FILES"/tzu | tail -n +4 | cmp "$FILES"/paginate -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Directories tested from here down
|
|
Athmane Madjoudj |
536354 |
# Setup a directory structure and populate it with files to work with
|
|
Athmane Madjoudj |
536354 |
#
|
|
Athmane Madjoudj |
536354 |
DIRTEST=/var/tmp/difftest
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
[[ -d "$DIRTEST" ]] && rm -r "$DIRTEST"
|
|
Athmane Madjoudj |
536354 |
mkdir "$DIRTEST"
|
|
Athmane Madjoudj |
536354 |
mkdir -p "$DIRTEST"/a/1
|
|
Athmane Madjoudj |
536354 |
mkdir -p "$DIRTEST"/b/1
|
|
Athmane Madjoudj |
536354 |
cp "$FILES"/lao "$DIRTEST"/a
|
|
Athmane Madjoudj |
536354 |
cp "$FILES"/lao "$DIRTEST"/b
|
|
Athmane Madjoudj |
536354 |
cp "$FILES"/tzu "$DIRTEST"/a
|
|
Athmane Madjoudj |
536354 |
cp "$FILES"/tao "$DIRTEST"/a/1
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check plain diff of 2 directories
|
|
Athmane Madjoudj |
536354 |
echo "Check basic directory comparison"
|
|
Athmane Madjoudj |
536354 |
diff "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -s --report-identical-files
|
|
Athmane Madjoudj |
536354 |
echo "Check identical files reported -s"
|
|
Athmane Madjoudj |
536354 |
diff -s "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_s -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check identical files reported --report-identical-files"
|
|
Athmane Madjoudj |
536354 |
diff --report-identical-files "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_s -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check recursive directory diff
|
|
Athmane Madjoudj |
536354 |
echo "Check recursive directory diff -r"
|
|
Athmane Madjoudj |
536354 |
diff -sr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_r -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check recursive directory diff --recursive"
|
|
Athmane Madjoudj |
536354 |
diff -s --recursive "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_r -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check -N --new-file output
|
|
Athmane Madjoudj |
536354 |
echo "Check directory diff -N"
|
|
Athmane Madjoudj |
536354 |
diff -Nsr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_N -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check directory diff --new-file"
|
|
Athmane Madjoudj |
536354 |
diff --new-file -sr "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_new_file -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check diff --unidirectional-new-file. Swap the command line arguments
|
|
Athmane Madjoudj |
536354 |
# around to make this work
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check directory diff --unidirectional-new-file"
|
|
Athmane Madjoudj |
536354 |
diff --unidirectional-new-file "$DIRTEST"/b "$DIRTEST"/a | cmp "$FILES"/dir_unidirectional -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check we can ignore patterns with diff in directory mode -x
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -x excludes file patterns"
|
|
Athmane Madjoudj |
536354 |
diff -x tz* "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check we can ignore patterns read from a file with diff in directory mode
|
|
Athmane Madjoudj |
536354 |
# -X --exclude-from=
|
|
Athmane Madjoudj |
536354 |
echo "Check diff -X excludes file patterns"
|
|
Athmane Madjoudj |
536354 |
diff -X "$FILES"/exclude "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Check diff --exclude-from excludes file patterns"
|
|
Athmane Madjoudj |
536354 |
diff --exclude-from="$FILES"/exclude "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_x -
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check we can exclude differences based on file name case
|
|
Athmane Madjoudj |
536354 |
# https://bugzilla.redhat.com/show_bug.cgi?id=719001
|
|
Athmane Madjoudj |
536354 |
#
|
|
Athmane Madjoudj |
536354 |
mv "$DIRTEST"/a/lao "$DIRTEST"/a/LAO
|
|
Athmane Madjoudj |
536354 |
echo "Checking --ignore-file-name-case"
|
|
Athmane Madjoudj |
536354 |
echo "see https://bugzilla.redhat.com/show_bug.cgi?id=719001"
|
|
Athmane Madjoudj |
536354 |
echo "If this fails then the bug has been fixed"
|
|
Athmane Madjoudj |
536354 |
diff --ignore-file-name-case "$DIRTEST"/a "$DIRTEST"/b | cmp "$FILES"/dir_case
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
# Check the --to-file option
|
|
Athmane Madjoudj |
536354 |
echo "Checking the --to-file option against a file"
|
|
Athmane Madjoudj |
536354 |
diff --to-file $FILES/lao $DIRTEST/a/LAO
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
echo "Checking the --to-file option against a directory"
|
|
Athmane Madjoudj |
536354 |
diff --to-file $FILES/lao $DIRTEST/b
|
|
Athmane Madjoudj |
536354 |
t_CheckExitStatus $?
|
|
Athmane Madjoudj |
536354 |
|
|
Athmane Madjoudj |
536354 |
rm -f "$F1"
|
|
Athmane Madjoudj |
536354 |
rm -f "$F2"
|
|
Athmane Madjoudj |
536354 |
rm -r "$DIRTEST"
|