3 # A very simple function test for gdiffmk.sh.
5 # Copyright (C) 2004-2018 Free Software Foundation, Inc.
6 # Written by Mike Bianchi <MBianchi@Foveal.com <mailto:MBianchi@Foveal.com>>
8 # This file is part of the gdiffmk utility, which is part of groff.
10 # groff is free software; you can redistribute it and/or modify it
11 # under the terms of the GNU General Public License as published by
12 # the Free Software Foundation, either version 3 of the License, or
13 # (at your option) any later version.
15 # groff is distributed in the hope that it will be useful, but WITHOUT
16 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
18 # License for more details.
20 # You should have received a copy of the GNU General Public License
21 # along with this program. If not, see <http://www.gnu.org/licenses/>.
22 # This file is part of GNU gdiffmk.
24 # abs_top_srcdir and abs_top_builddir are set by AM_TESTS_ENVIRONMENT
25 # (defined in Makefile.am) when running make check
27 srcdir=${abs_top_srcdir}/contrib/gdiffmk/tests
29 command=${abs_top_builddir}/gdiffmk
31 # Test the number of arguments and the first argument.
34 rm -fv result* tmp_file*
40 echo >&2 "$0 [ clean | run ]
41 Run a few simple tests on '${command}'."'
43 clean Remove the result? and tmp_file? files.
62 failure_count=`expr ${failure_count} + 1`
67 trap 'rm -f ${tmpfile}' 0 1 2 3 15
73 ${command} ${srcdir}/file1 ${srcdir}/file2 ${ResultFile} 2>${tmpfile}
74 cat ${tmpfile} >>${ResultFile}
75 TestResult ${srcdir}/baseline ${ResultFile}
78 # OUTPUT to stdout by default
80 ${command} ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
81 TestResult ${srcdir}/baseline ${ResultFile}
84 # OUTPUT to stdout via - argument
86 ${command} ${srcdir}/file1 ${srcdir}/file2 - >${ResultFile} 2>&1
87 TestResult ${srcdir}/baseline ${ResultFile}
90 # FILE1 from standard input via - argument
92 ${command} - ${srcdir}/file2 <${srcdir}/file1 >${ResultFile} 2>&1
93 TestResult ${srcdir}/baseline ${ResultFile}
96 # FILE2 from standard input via - argument
98 ${command} ${srcdir}/file1 - <${srcdir}/file2 >${ResultFile} 2>&1
99 TestResult ${srcdir}/baseline ${ResultFile}
102 # Different values for addmark, changemark, deletemark
104 ${command} -aA -cC -dD ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
105 TestResult ${srcdir}/baseline.6 ${ResultFile}
108 # Different values for addmark, changemark, deletemark
109 # Alternate format of -a -c and -d flag arguments
111 ${command} -a A -c C -d D ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
112 TestResult ${srcdir}/baseline.6a ${ResultFile}
115 # Test for accidental file overwrite.
117 cp ${srcdir}/file2 tmp_file.7
118 ${command} -aA -dD -cC ${srcdir}/file1 tmp_file.7 tmp_file.7 \
120 TestResult ${srcdir}/baseline.7 ${ResultFile}
125 ${command} -D ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
126 TestResult ${srcdir}/baseline.8 ${ResultFile}
129 # Test -D and -M options
131 ${command} -D -M '<<<<' '>>>>' \
132 ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
133 TestResult ${srcdir}/baseline.9 ${ResultFile}
136 # Test -D and -M options
137 # Alternate format of -M argument.
139 ${command} -D -M'<<<<' '>>>>' \
140 ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
141 TestResult ${srcdir}/baseline.9a ${ResultFile}
144 # Test -D and -B options
146 ${command} -D -B ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1
147 TestResult ${srcdir}/baseline.10 ${ResultFile}
150 echo failure_count ${failure_count}