1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
|
#!/bin/bash
set -e
$PREPARE_DEFAULT > /dev/null
$INCLUDE_FUNCS
cd $WC
file=diff-file
copy=copy-file
log=$LOGDIR/026.diff-log
echo "line" > $file
$BINq ci -m "repos-vers" -o delay=yes
echo "something else" > $file
if [[ `$BINdflt diff $file | wc -l` -eq 6 ]]
then
$SUCCESS "We get a diff"
else
$ERROR "No diff shown."
fi
# Only headerline
if [[ `FSVS_DIFF_PRG=true $BINdflt diff $file | wc -l` -eq 1 ]]
then
$SUCCESS "FSVS_DIFF_PRG is honored"
else
$ERROR "FSVS_DIFF_PRG doesn't work?"
fi
FSVS_DIFF_PRG=true $BINdflt diff -v $file > $log
# We cannot be absolutely sure that the mtime doesn't wrap into the next
# second, so there might be +- lines for meta-data.
if [[ `grep -E '^.(Mode|MTime|Owner|Group): ' $log | wc -l` -lt 4 ]]
then
$ERROR "Meta-data output missing?"
else
$SUCCESS "Meta-data is printed"
fi
$BINq revert $file -odelay=yes
if [[ `$BINdflt diff $file | wc -l` -eq 0 ]]
then
$SUCCESS "No diff if not changed"
else
$ERROR "Too much output for unchanged files!"
fi
# Tests for diff of copied entries.
cp -a $file $copy
$BINq cp $file $copy
# We don't use -a; because of the sleep above we get a different timestamp,
# and so the header is printed.
if [[ `$BINdflt diff $copy | wc -l` -le 1 ]]
then
$SUCCESS "Diff for unchanged, copied, mtime entry"
else
$ERROR "Diff for unchanged, copied, mtime wrong"
fi
cp -a $file $copy
# Now they should have the same timestamp, so no change.
if [[ `$BINdflt diff $copy | wc -l` -le 1 ]]
then
$SUCCESS "Diff for unchanged, copied entry"
else
$BINdflt diff $copy
$ERROR "Diff for unchanged, copied unexpected"
fi
echo X > $copy
$BINdflt diff -r HEAD $copy > $log
if [[ `wc -l < $log` -eq 6 ]]
then
$SUCCESS "Diff for copied"
else
wc -l < $log
$ERROR "Diff for copied wrong - expected 6 lines"
fi
chmod 700 $copy
$BINq ps a b $copy
$BINq ci -m 1 -o delay=yes
echo Y > $copy
chmod 550 $copy
$BINq ps a c $copy
# TODO: user-defined property diff
if [[ `$BINdflt diff -v $copy | wc -l` -eq 12 ]]
then
$SUCCESS "Diff for changed copy"
else
$BINdflt diff -v $copy
$ERROR "Diff for changed copy, expected mode change"
fi
# Try colordiff auto mode
$BINdflt diff -v $copy -o colordiff="" > /dev/null
# Try error handling
if $BINdflt diff $copy -o colordiff=mustneverexist_invalidbinary.$$.$RANDOM > $log 2>&1
then
$ERROR "Doesn't error out for an invalid colordiff name?"
else
$SUCCESS "Reports bad names for colordiff"
fi
# No temporary file may be left behind.
if ls $copy.* 2> /dev/null
then
$ERROR "Temporary file left behind."
fi
# True immediately exits
if $BINdflt diff $copy -o colordiff=true > /dev/null 2>&1
then
$ERROR "Doesn't error out for a non-reading colordiff?"
else
$SUCCESS "Reports stopping colordiffs"
fi
# No temporary file may be left behind.
if ls $copy.* 2> /dev/null
then
$ERROR "Temporary file left behind."
fi
# EPIPE?
if $BINdflt diff $copy -o colordiff=cat | true
then
$SUCCESS "Ignores EPIPE"
else
$ERROR "Doesn't handle EPIPE"
fi
# No temporary file may be left behind.
if ls $copy.* 2> /dev/null
then
$ERROR "Temporary file left behind."
fi
# Test "diff -rX" against entries in subdirectories, and compare against
# "live" diff.
# The header lines (current version, timestamp, etc.) are different and
# made equal for comparision.
$BINq ci -m1 -odelay=yes > $log
rev=`grep "revision " $log | tail -1 | cut -f2 -d" " | cut -f1 -d" "`
fn=tree/b/2/file-x
equalizer="perl -pe s#($fn).*#filename_and_so_on#"
echo $RANDOM $$ > $fn
$BINdflt diff $fn | $equalizer > $log
$BINq ci -m1
# echo aaa > $fn # for verification that the test mechanism works
if $BINdflt diff -r$rev $fn | $equalizer | diff -u - $log
then
$SUCCESS "diff -rX"
else
$ERROR "'diff -rX' gives a different answer"
fi
# Test diff over special entries
ln -s old X
$BINq ci -m1 -odelay=yes > $log
rev1=`grep "revision " $log | tail -1 | cut -f2 -d" " | cut -f1 -d" "`
ln -sf new X
function testdiff
{
$BINq diff "$@" > $log
# There are additional lines "no linefeed" and "special entry changed".
if [[ `wc -l < $log` -ne 9 ]]
then
cat $log
$ERROR "'diff "$@"' line count wrong"
fi
if grep -F -- '-link old' < $log &&
grep -F -- '+link new' < $log
then
$SUCCESS "'diff "$@"' ok"
else
cat $log
$ERROR "'diff "$@"' output wrong"
fi
}
#testdiff
#testdiff X
testdiff X -r$rev1
$BINq ci -m1 -odelay=yes > $log
rev2=`grep "revision " $log | tail -1 | cut -f2 -d" " | cut -f1 -d" "`
testdiff -r$rev1:$rev2
testdiff -r$rev1:$rev2 X
################# other tests
exit
$PREPARE_CLEAN > /dev/null
cd $WC
mkdir d1 d2
echo 1 > d1/file-1
echo 2 > d2/file-2
echo 3 > d2/file-3
$BINq ci -m1 > $log
rev1=`grep "revision " $log | tail -1 | cut -f2 -d" " | cut -f1 -d" "`
echo 1a > d1/file-1
echo 2a > d2/file-2
echo 3a > d2/file-3
$BINq ci -m2 > $log
rev2=`grep "revision " $log | tail -1 | cut -f2 -d" " | cut -f1 -d" "`
$BINdflt diff -r$rev1 d1 > $log
if [[ `wc -l < $log` -eq 6 ]]
then
$SUCCESS "diff -rX takes only specified files"
else
$ERROR "wrong output on diff -rX"
fi
$BINdflt diff -r4:5 d2/file-2/file-2
|