blob: a13d2f87f53c22c3665be7255caf01b2cff3de1e (
plain)
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
|
#!/bin/sh
# A very simple function test for gdiffmk.sh.
command=../gdiffmk.sh
# Test the number of arguments and the first argument.
case $#-$1 in
1-clean )
rm -fv test_result? tmp_file?
exit 0
;;
1-run )
;;
* )
echo >&2 "$0 [ clean | run ]
Run a few simple tests on \`${command}'."'
clean Remove the test_result? and tmp_file? files.
run Run the tests.
'
exit 255
;;
esac
function TestResult {
if diff $1 $2
then
echo $2 PASSED
else
echo $2 TEST FAILED '\a'
fi
}
tmpfile=/tmp/$$
trap 'rm -f ${tmpfile}' 0 1 2 3 15
# 3 file arguments
ResultFile=test_result1
sh ${command} file1 file2 ${ResultFile} 2>${tmpfile}
cat ${tmpfile} >>${ResultFile}
TestResult test_baseline ${ResultFile}
# OUTPUT to stdout by default
ResultFile=test_result2
sh ${command} file1 file2 >${ResultFile} 2>&1
TestResult test_baseline ${ResultFile}
# OUTPUT to stdout via - argument
ResultFile=test_result3
sh ${command} file1 file2 - >${ResultFile} 2>&1
TestResult test_baseline ${ResultFile}
# FILE1 from standard input via - argument
ResultFile=test_result4
sh ${command} - file2 <file1 >${ResultFile} 2>&1
TestResult test_baseline ${ResultFile}
# FILE2 from standard input via - argument
ResultFile=test_result5
sh ${command} file1 - <file2 >${ResultFile} 2>&1
TestResult test_baseline ${ResultFile}
# Different values for addmark, changemark, deletemark
ResultFile=test_result6
sh ${command} -aA -cC -dD file1 file2 >${ResultFile} 2>&1
TestResult test_baseline6 ${ResultFile}
# Test for accidental file overwrite.
ResultFile=test_result7
cp file2 tmp_file7
sh ${command} -aA -dD -cC file1 tmp_file7 tmp_file7 >${ResultFile} 2>&1
TestResult test_baseline7 ${ResultFile}
|