summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/doc/latex/textpos/t/runtests
blob: d7264da52f824f4031edf5f5a2eb0be5bb0df80b (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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#! /bin/sh -
#
# $Id: runtests,v 1.4 2005/08/30 18:19:12 norman Exp $
#
# Run a series of tests on LaTeX files.  The directory contains a collection
# of documents named `t<number>.tex', and these are processed in turn and their
# output diffed against `t<number>.correct.dvi'.  Exit status is the
# number of failures.
#
# Run without an argument, and if there is no file runtests.filelist,
# this runs all the tests in the directory; run with an argument, it
# runs only the specified tests.
#
# If there is no argument, but a file runtests.filelist exists, use
# that file's contents as the list of tests to run.  This means that
# we can make it easy to do a subset of the tests repeatedly while
# testing.
#
# The only we we really have of testing whether the binary DVI files
# differ is by comparing them using cmp, which simply reports the
# byte-offset where they differ.  This isn't terribly helpful, and
# even examining the files using dv2dt doesn't help much.  It's also
# probably rather sensitive to things like the version of hyperref
# which is being used.  Also, since TeX puts a timestamp in DVI files, 
# we have to ignore the first 50 bytes or so (see a thread with the
# subject `diff for dvi files', in comp.text.tex, in May 2001.
#
# If the option --keep is present, then it doesn't delete temporary files.

UsageString="$0 [--keep] [filename...]"
deletetemp=true
LS=/bin/ls


filelist=""

while [ $# -gt 0 ]; do
    case $1 in
    --keep) deletetemp=false ;;
    --*) echo "Usage: $UsageString"
	 exit 1
	 ;;
    *) filelist="$filelist $1"
	 ;;
    esac
    shift
done

# If filelist is null, and a file runtests.filelist exists, use that
# file's contents as the value of filelist.
if [ -z "$filelist" -a -f runtests.filelist ]; then
    echo "Reading filelist from runtests.filelist"
    filelist=`cat runtests.filelist`
fi

# Check filelist is non-null, and make it t* if it is.
if [ -z "$filelist" ]; then
    filelist=`$LS | grep '^t[0-9]*\.tex$' | sed 's/\.tex//'`
fi



nfailures=0

for name in $filelist
do
	echo -n "$name... "
	# Make sure we run twice, if there's no preexisting aux file.
	test -f $name.aux || latex $name.tex >$name.stdout 2>$name.stderr
	latex $name.tex >$name.stdout 2>$name.stderr
	testval=$?
	#test -f $name.dvi && mv $name.dvi $name.dvi.tmp

	if [ $testval != 0 ]; then
	    echo "failed (exited with error status $testval)"
	    nfailures=`expr $nfailures + 1`
	    $deletetemp && rm -f $name.stdout $name.stderr $name.dvi $name*.tmp
	elif [ -r "$name.correct.dvi" ]; then
	    cmp -i50 $name.dvi $name.correct.dvi >$name.diff
	    rval=$?
	    if [ $rval != 0 ]; then
                make $name.dtl.diff >/dev/null
		echo "failed (results in $name.dtl.diff)"
		nfailures=`expr $nfailures + 1`
	    else
		echo "ok"
		$deletetemp && rm -f $name.diff $name.stdout $name.stderr $name.dvi $name*.tmp
	    fi
	else
		echo "apparently OK, but no correct results to compare"
		mv $name.dvi $name.correct.dvi
		echo "    (now in $name.correct.dvi)"
		$deletetemp && rm -f $name*.tmp
	fi
done

echo "$nfailures failed tests"

exit $nfailures