* tests/tests.sh: Renamed to...
[s-roff.git] / contrib / gdiffmk / tests / runtests.sh
bloba13d2f87f53c22c3665be7255caf01b2cff3de1e
1 #!/bin/sh
2 # A very simple function test for gdiffmk.sh.
4 command=../gdiffmk.sh
6 # Test the number of arguments and the first argument.
7 case $#-$1 in
8 1-clean )
9 rm -fv test_result? tmp_file?
10 exit 0
12 1-run )
14 * )
15 echo >&2 "$0 [ clean | run ]
16 Run a few simple tests on \`${command}'."'
18 clean Remove the test_result? and tmp_file? files.
19 run Run the tests.
21 exit 255
23 esac
25 function TestResult {
26 if diff $1 $2
27 then
28 echo $2 PASSED
29 else
30 echo $2 TEST FAILED '\a'
34 tmpfile=/tmp/$$
35 trap 'rm -f ${tmpfile}' 0 1 2 3 15
37 # 3 file arguments
38 ResultFile=test_result1
39 sh ${command} file1 file2 ${ResultFile} 2>${tmpfile}
40 cat ${tmpfile} >>${ResultFile}
41 TestResult test_baseline ${ResultFile}
43 # OUTPUT to stdout by default
44 ResultFile=test_result2
45 sh ${command} file1 file2 >${ResultFile} 2>&1
46 TestResult test_baseline ${ResultFile}
48 # OUTPUT to stdout via - argument
49 ResultFile=test_result3
50 sh ${command} file1 file2 - >${ResultFile} 2>&1
51 TestResult test_baseline ${ResultFile}
53 # FILE1 from standard input via - argument
54 ResultFile=test_result4
55 sh ${command} - file2 <file1 >${ResultFile} 2>&1
56 TestResult test_baseline ${ResultFile}
58 # FILE2 from standard input via - argument
59 ResultFile=test_result5
60 sh ${command} file1 - <file2 >${ResultFile} 2>&1
61 TestResult test_baseline ${ResultFile}
63 # Different values for addmark, changemark, deletemark
64 ResultFile=test_result6
65 sh ${command} -aA -cC -dD file1 file2 >${ResultFile} 2>&1
66 TestResult test_baseline6 ${ResultFile}
68 # Test for accidental file overwrite.
69 ResultFile=test_result7
70 cp file2 tmp_file7
71 sh ${command} -aA -dD -cC file1 tmp_file7 tmp_file7 >${ResultFile} 2>&1
72 TestResult test_baseline7 ${ResultFile}