PageRenderTime 6ms CodeModel.GetById 1ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/contrib/groff/contrib/gdiffmk/tests/runtests.in

https://bitbucket.org/freebsd/freebsd-head/
Autoconf | 98 lines | 65 code | 18 blank | 15 comment | 1 complexity | f73e073ff51090802624bd311e068da9 MD5 | raw file
 1#! /bin/sh
 2#	A very simple function test for gdiffmk.sh.
 3
 4srcdir=@srcdir@
 5
 6command=../gdiffmk
 7
 8#	Test the number of arguments and the first argument.
 9case $#-$1 in
101-clean )
11	rm -fv test_result* tmp_file*
12	exit 0
13	;;
141-run )
15	;;
16* )
17	echo >&2 "$0 [ clean | run ]
18Run a few simple tests on \`${command}'."'
19
20clean	Remove the test_result? and tmp_file? files.
21run	Run the tests.
22'
23	exit 255
24	;;
25esac
26
27function TestResult {
28	if cmp -s $1 $2
29	then
30		echo $2 PASSED
31	else
32		echo ''
33		echo $2 TEST FAILED
34		diff $1 $2
35		echo ''
36	fi
37}
38
39tmpfile=/tmp/$$
40trap 'rm -f ${tmpfile}' 0 1 2 3 15
41
42#	Run tests.
43
44#	3 file arguments
45ResultFile=test_result1
46${command}  ${srcdir}/file1  ${srcdir}/file2 ${ResultFile} 2>${tmpfile}
47cat ${tmpfile} >>${ResultFile}
48TestResult ${srcdir}/test_baseline ${ResultFile}
49
50#	OUTPUT to stdout by default
51ResultFile=test_result2
52${command}  ${srcdir}/file1  ${srcdir}/file2  >${ResultFile} 2>&1
53TestResult ${srcdir}/test_baseline ${ResultFile}
54
55#	OUTPUT to stdout via  -  argument
56ResultFile=test_result3
57${command}  ${srcdir}/file1  ${srcdir}/file2 - >${ResultFile} 2>&1
58TestResult ${srcdir}/test_baseline ${ResultFile}
59
60#	FILE1 from standard input via  -  argument
61ResultFile=test_result4
62${command}  - ${srcdir}/file2 <${srcdir}/file1  >${ResultFile} 2>&1
63TestResult ${srcdir}/test_baseline ${ResultFile}
64
65#	FILE2 from standard input via  -  argument
66ResultFile=test_result5
67${command}  ${srcdir}/file1 - <${srcdir}/file2  >${ResultFile} 2>&1
68TestResult ${srcdir}/test_baseline ${ResultFile}
69
70#	Different values for addmark, changemark, deletemark
71ResultFile=test_result6
72${command}  -aA -cC -dD  ${srcdir}/file1 ${srcdir}/file2  >${ResultFile} 2>&1
73TestResult ${srcdir}/test_baseline6 ${ResultFile}
74
75#	Test for accidental file overwrite.
76ResultFile=test_result7
77cp ${srcdir}/file2 tmp_file7
78${command}  -aA -dD -cC  ${srcdir}/file1 tmp_file7  tmp_file7	\
79							>${ResultFile} 2>&1
80TestResult ${srcdir}/test_baseline7 ${ResultFile}
81
82#	Test -D option
83ResultFile=test_result8
84${command}  -D  ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
85TestResult ${srcdir}/test_baseline8 ${ResultFile}
86
87#	Test -D  and  -M  options
88ResultFile=test_result9
89${command}  -D  -M '<<<<' '>>>>'				\
90			${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
91TestResult ${srcdir}/test_baseline9 ${ResultFile}
92
93#	Test -D  and  -B  options
94ResultFile=test_result10
95${command}  -D  -B  ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
96TestResult ${srcdir}/test_baseline10 ${ResultFile}
97
98#	EOF