Skip to content

Commit ffb83e6

Browse files
authored
Merge pull request #318 from fabionatali/master
Fix test.sh which used to fail in some circumstances
2 parents 36849c3 + e97f413 commit ffb83e6

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

test.sh

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ fi
130130
# Actual tests are below. If you add test cases above, these need to be tweaked.
131131
#---------------------------------------------------------------------------------
132132

133-
134-
cat ${DUC_TEST_DIR}.out | grep -q "Indexed 77 files and 47 directories, (91869B apparent, 540672B actual)"
133+
# An exact match is expected on the apparent size; the actual size may vary.
134+
cat ${DUC_TEST_DIR}.out | grep -q "Indexed 77 files and 47 directories, (91869B apparent, [0-9]*B actual)"
135135

136136
if [ "$?" = "0" ]; then
137137
echo "report: ok"
@@ -153,16 +153,26 @@ if [ "$?" != "0" ]; then
153153
exit 1
154154
fi
155155

156-
testsum="33e2be27a9e70e81d4006a2d7b555948"
156+
# When two or more hard links point to the same file and when running duc with
157+
# the `--check-hard-links' option, only one of the hard links will be
158+
# counted. However, duc may pick up and display a different hard link depending
159+
# on the system it is being run on. Since our tests include three hard links to
160+
# the same file, we should be expecting three possible outcomes, all equally
161+
# valid, each corresponding to one of the following MD5 checksums.
162+
testsum0="78dbf880ef6917ea665fddb5ebb44428"
163+
testsum1="38ab7b7d1ec6ac57d672c5618371386d"
164+
testsum2="33e2be27a9e70e81d4006a2d7b555948"
157165
md5sum ${DUC_TEST_DIR}.out > /tmp/.duc.md5sum
158-
grep -q $testsum /tmp/.duc.md5sum
166+
grep -q "$testsum0\|$testsum1\|$testsum2" /tmp/.duc.md5sum
159167

160168
if [ "$?" = "0" ]; then
161169
echo "md5sum: ok"
162170
else
163171
echo "md5sum: failed"
164-
echo "expected: "
165-
echo "$testsum ${DUC_TEST_DIR}.out"
172+
echo "expected one of: "
173+
echo "$testsum0 ${DUC_TEST_DIR}.out"
174+
echo "$testsum1 ${DUC_TEST_DIR}.out"
175+
echo "$testsum2 ${DUC_TEST_DIR}.out"
166176
echo "got: "
167177
cat /tmp/.duc.md5sum
168178
exit 1

0 commit comments

Comments
 (0)