diff options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/gdiffmk/ChangeLog | 21 | ||||
-rw-r--r-- | contrib/gdiffmk/gdiffmk.am | 10 | ||||
-rw-r--r-- | contrib/gdiffmk/tests/baseline.7 | 2 | ||||
-rwxr-xr-x | contrib/gdiffmk/tests/gdiffmk_tests.sh | 9 | ||||
-rwxr-xr-x | contrib/gdiffmk/tests/runtests.sh | 168 |
5 files changed, 120 insertions, 90 deletions
diff --git a/contrib/gdiffmk/ChangeLog b/contrib/gdiffmk/ChangeLog index c34cb37a3..28c65d32d 100644 --- a/contrib/gdiffmk/ChangeLog +++ b/contrib/gdiffmk/ChangeLog @@ -1,3 +1,24 @@ +2023-02-09 G. Branden Robinson <g.branden.robinson@gmail.com> + + Revise test regime. Reduce amount of indirection required to + run a test, and directly use the same script for standalone and + Automake-integrated testing. + + * tests/gdiffmk_tests.sh: Delete. + * tests/runtests.sh: Revise to search for test artifact input + and output directories (source vs. build). Drop argument + argument processing, converting two modes ("run" and "clean") + into one (run, with cleaning afterward). Also ensure we use the + build directory to construct "tmp_file.7". Update authorship + credit so that Mike Bianchi isn't asked to support it. + + * tests/baseline.7: Update expected test output. + + * gdiffmk.am (TESTS): Run "runtests.sh" instead of + "gdiffmk_tests.sh". + (clean-local, clean_gdiffmk_check): Drop targets now that the + test script cleans up after itself. + 2023-02-06 G. Branden Robinson <g.branden.robinson@gmail.com> * tests/runtests.sh: Refactor file handling. Use narrower globs diff --git a/contrib/gdiffmk/gdiffmk.am b/contrib/gdiffmk/gdiffmk.am index 0770340f1..46f224ba8 100644 --- a/contrib/gdiffmk/gdiffmk.am +++ b/contrib/gdiffmk/gdiffmk.am @@ -22,14 +22,13 @@ ######################################################################## gdiffmk_srcdir = $(top_srcdir)/contrib/gdiffmk bin_SCRIPTS += gdiffmk -TESTS += contrib/gdiffmk/tests/gdiffmk_tests.sh +TESTS += contrib/gdiffmk/tests/runtests.sh man1_MANS += contrib/gdiffmk/gdiffmk.1 EXTRA_DIST += \ contrib/gdiffmk/gdiffmk.1.man \ contrib/gdiffmk/ChangeLog \ contrib/gdiffmk/README \ contrib/gdiffmk/gdiffmk.sh \ - contrib/gdiffmk/tests/gdiffmk_tests.sh \ contrib/gdiffmk/tests/runtests.sh \ contrib/gdiffmk/tests/baseline \ contrib/gdiffmk/tests/baseline.6 \ @@ -52,13 +51,6 @@ gdiffmk: $(gdiffmk_srcdir)/gdiffmk.sh >$@ \ && chmod +x $@ -clean-local: clean_gdiffmk_check -clean_gdiffmk_check: - if test -d $(top_builddir)/contrib/gdiffmk/tests; then \ - cd $(top_builddir)/contrib/gdiffmk/tests && \ - $(abs_top_srcdir)/contrib/gdiffmk/tests/runtests.sh clean; \ - fi - # Local Variables: # mode: makefile-automake diff --git a/contrib/gdiffmk/tests/baseline.7 b/contrib/gdiffmk/tests/baseline.7 index df23363b2..4a83af63b 100644 --- a/contrib/gdiffmk/tests/baseline.7 +++ b/contrib/gdiffmk/tests/baseline.7 @@ -1,2 +1,2 @@ gdiffmk: The FILE2 and OUTPUT arguments both point to the same file, -gdiffmk: 'tmp_file.7', and it would be overwritten. +gdiffmk: './contrib/gdiffmk/tests/tmp_file.7', and it would be overwritten. diff --git a/contrib/gdiffmk/tests/gdiffmk_tests.sh b/contrib/gdiffmk/tests/gdiffmk_tests.sh deleted file mode 100755 index e74d59419..000000000 --- a/contrib/gdiffmk/tests/gdiffmk_tests.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh - -# Execute runtests.sh in the builddir - -set -e - -mkdir -p ${abs_top_builddir}/contrib/gdiffmk/tests -cd ${abs_top_builddir}/contrib/gdiffmk/tests -${abs_top_srcdir}/contrib/gdiffmk/tests/runtests.sh run diff --git a/contrib/gdiffmk/tests/runtests.sh b/contrib/gdiffmk/tests/runtests.sh index 184864698..51cf855a3 100755 --- a/contrib/gdiffmk/tests/runtests.sh +++ b/contrib/gdiffmk/tests/runtests.sh @@ -2,8 +2,9 @@ # # A very simple function test for gdiffmk.sh. # -# Copyright (C) 2004-2020 Free Software Foundation, Inc. -# Written by Mike Bianchi <MBianchi@Foveal.com <mailto:MBianchi@Foveal.com>> +# Copyright (C) 2004-2020, 2023 Free Software Foundation, Inc. +# Written by Mike Bianchi <MBianchi@Foveal.com>. +# Subsequent modifications by G. Branden Robinson. # This file is part of the gdiffmk utility, which is part of groff. @@ -21,34 +22,60 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # This file is part of GNU gdiffmk. -# abs_top_srcdir and abs_top_builddir are set by AM_TESTS_ENVIRONMENT -# (defined in Makefile.am) when running make check - -srcdir=${abs_top_srcdir}/contrib/gdiffmk/tests - -command=${abs_top_builddir}/gdiffmk - -# Test the number of arguments and the first argument. -case "$#-$1" in -1-clean ) - rm -fv result.* tmp_file.* - exit 0 - ;; -1-run ) - ;; -* ) - echo >&2 "$0 [ clean | run ] -Run a few simple tests on '${command}'."' - -clean Remove the result.? and tmp_file.? files. -run Run the tests. -' - exit 255 - ;; -esac +# abs_top_out_dir is set by AM_TESTS_ENVIRONMENT (defined in +# Makefile.am) when running "make check". + +gdiffmk=${abs_top_out_dir:-.}/gdiffmk + +# Locate directory containing our test artifacts. +in_dir= + +for srcroot in . .. ../.. +do + # Look for a source file characteristic of the groff source tree. + if ! [ -f "$srcroot"/ChangeLog.115 ] + then + continue + fi + + d=$srcroot/contrib/gdiffmk/tests + if [ -d "$d" ] + then + in_dir=$d + break + fi +done + +# If we can't find it, we can't test. +if [ -z "$in_dir" ] +then + echo "$0: cannot locate test artifact input directory" >&2 + exit 77 # skip +fi + +# Locate directory where we'll put the test output. +out_dir= + +for buildroot in . .. ../.. +do + d=$buildroot/contrib/gdiffmk/tests + if [ -d "$d" ] + then + out_dir=$d + break + fi +done + +# If we can't find it, we can't test. +if [ -z "$out_dir" ] +then + echo "$0: cannot locate test artifact output directory" >&2 + exit 77 # skip +fi exit_code=0 # Success failure_count=0 + TestResult () { if cmp -s $1 $2 then @@ -64,7 +91,7 @@ TestResult () { } CleanUp () { - rm -f tmp_file.* ${tmpfile} + rm -f ${out_dir}/result.* ${out_dir}/tmp_file.* ${tmpfile} } tmpfile=${TMPDIR:-/tmp}/$$ @@ -74,88 +101,87 @@ trap 'trap "" HUP INT QUIT TERM; CleanUp; kill -s INT $$' \ # Run tests. # 3 file arguments -ResultFile=result.1 -${command} ${srcdir}/file1 ${srcdir}/file2 ${ResultFile} 2>${tmpfile} +ResultFile=${out_dir}/result.1 +${gdiffmk} ${in_dir}/file1 ${in_dir}/file2 ${ResultFile} 2>${tmpfile} cat ${tmpfile} >>${ResultFile} -TestResult ${srcdir}/baseline ${ResultFile} - +TestResult ${in_dir}/baseline ${ResultFile} # OUTPUT to stdout by default -ResultFile=result.2 -${command} ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline ${ResultFile} - +ResultFile=${out_dir}/result.2 +${gdiffmk} ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline ${ResultFile} # OUTPUT to stdout via - argument -ResultFile=result.3 -${command} ${srcdir}/file1 ${srcdir}/file2 - >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline ${ResultFile} - +ResultFile=${out_dir}/result.3 +${gdiffmk} ${in_dir}/file1 ${in_dir}/file2 - >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline ${ResultFile} # FILE1 from standard input via - argument -ResultFile=result.4 -${command} - ${srcdir}/file2 <${srcdir}/file1 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline ${ResultFile} +ResultFile=${out_dir}/result.4 +${gdiffmk} - ${in_dir}/file2 <${in_dir}/file1 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline ${ResultFile} # FILE2 from standard input via - argument -ResultFile=result.5 -${command} ${srcdir}/file1 - <${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline ${ResultFile} +ResultFile=${out_dir}/result.5 +${gdiffmk} ${in_dir}/file1 - <${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline ${ResultFile} # Different values for addmark, changemark, deletemark -ResultFile=result.6 -${command} -aA -cC -dD ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.6 ${ResultFile} +ResultFile=${out_dir}/result.6 +${gdiffmk} -aA -cC -dD ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.6 ${ResultFile} # Different values for addmark, changemark, deletemark # Alternate format of -a -c and -d flag arguments -ResultFile=result.6a -${command} -a A -c C -d D ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.6a ${ResultFile} +ResultFile=${out_dir}/result.6a +${gdiffmk} -a A -c C -d D ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.6a ${ResultFile} # Test for accidental file overwrite. -ResultFile=result.7 -cp ${srcdir}/file2 tmp_file.7 -${command} -aA -dD -cC ${srcdir}/file1 tmp_file.7 tmp_file.7 \ +ResultFile=${out_dir}/result.7 +TempFile=${out_dir}/tmp_file.7 +cp ${in_dir}/file2 "$TempFile" +${gdiffmk} -aA -dD -cC ${in_dir}/file1 "$TempFile" "$TempFile" \ >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.7 ${ResultFile} +TestResult ${in_dir}/baseline.7 ${ResultFile} # Test -D option -ResultFile=result.8 -${command} -D ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.8 ${ResultFile} +ResultFile=${out_dir}/result.8 +${gdiffmk} -D ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.8 ${ResultFile} # Test -D and -M options -ResultFile=result.9 -${command} -D -M '<<<<' '>>>>' \ - ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.9 ${ResultFile} +ResultFile=${out_dir}/result.9 +${gdiffmk} -D -M '<<<<' '>>>>' \ + ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.9 ${ResultFile} # Test -D and -M options # Alternate format of -M argument. -ResultFile=result.9a -${command} -D -M'<<<<' '>>>>' \ - ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.9a ${ResultFile} +ResultFile=${out_dir}/result.9a +${gdiffmk} -D -M'<<<<' '>>>>' \ + ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.9a ${ResultFile} # Test -D and -B options -ResultFile=result.10 -${command} -D -B ${srcdir}/file1 ${srcdir}/file2 >${ResultFile} 2>&1 -TestResult ${srcdir}/baseline.10 ${ResultFile} +ResultFile=${out_dir}/result.10 +${gdiffmk} -D -B ${in_dir}/file1 ${in_dir}/file2 >${ResultFile} 2>&1 +TestResult ${in_dir}/baseline.10 ${ResultFile} echo failure_count ${failure_count} +# You can comment out the following line to examine failing cases. CleanUp exit ${exit_code} -# EOF +# vim:set ai et sw=4 ts=4 tw=72: |