summaryrefslogtreecommitdiff
path: root/util/defs.in
blob: f70b1e71a84532ec2e6cbb7b7a79fe7f40969001 (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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
# -*- shell-script -*-
# @configure_input@
#
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 
# 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
# (This file was originally part of GNU Automake.)
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Defines for Automake testing environment.
# Tom Tromey <tromey@cygnus.com>

# Be Bourne compatible.
# (Snippet copied from configure's initialization in Autoconf 2.57.)
if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  emulate sh
  NULLCMD=:
  # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  # is contrary to our usage.  Disable this feature.
  alias -g '${1+"$@"}'='"$@"'
elif test -n "${BASH_VERSION+set}" && (set -o posix) >/dev/null 2>&1; then
  set -o posix
fi

# Ensure we are running from the right directory.
test -f ./defs || {
   echo "defs: not found in current directory" 1>&2
   exit 1
}

# If srcdir is not set, then we are not running from `make check', be verbose.
if test -z "$srcdir"; then
   VERBOSE=x
   # compute $srcdir.
   srcdir=`echo "$0" | sed -e 's,/[^\\/]*$,,'`
   test $srcdir = $0 && srcdir=.
fi

# Ensure $srcdir is set correctly.
test -f $srcdir/defs.in || {
   echo "$srcdir/defs.in not found, check \$srcdir" 1>&2
   exit 1
}

me=`echo "$0" | sed -e 's,.*[\\/],,;s/\.test$//'`

# See how redirections should work.  User can set VERBOSE to see all
# output.
test -z "$VERBOSE" && {
   exec > /dev/null 2>&1
}

# Make sure we override the user shell.
SHELL='@SHELL@'
export SHELL

srcdir_abs=`cd $srcdir && pwd`
test -z "$TEXI2DVI" && TEXI2DVI=$srcdir_abs/texi2dvi

# be sure we use texi2dvi and texindex from our own directory, not
# whatever happens to be in the path.
echo "defs: prepending $srcdir_abs to PATH for testing."
PATH="@abs_builddir@:@abs_srcdir@:$PATH"

# Some shells forget to export modified environment variables.
# (See note about `export' in the Autoconf manual.)
export PATH

# User can override various tools used.
test -z "$PERL" && PERL='@PERL@'

if test -n "$required"
then
  for tool in $required
  do
    # Check that each required tool is present.
    case $tool in
      hevea)
        # HeVeA supports -version only.  Use configure to find it.
        test -n "@HEVEA@" || exit 77
	;;
      tex)
        # No all versions of Tex support `--version', so we use
        # a configure check.
        test -n "@TEX@" || exit 77
	;;
      # Generic case: the tool must support --version.
      *)
	echo "$me: running $tool --version"
	( $tool --version ) || exit 77
	;;
    esac
  done
fi


# Always use an absolute srcdir.  Otherwise symlinks made in subdirs
# of the test dir just won't work.
case "$srcdir" in
 [\\/]* | ?:[\\/]*)
    ;;

 *)
    srcdir=`CDPATH=: && cd "$srcdir" && pwd`
    ;;
esac

chmod -R a+rwx testSubDir > /dev/null 2>&1
rm -rf testSubDir > /dev/null 2>&1
mkdir testSubDir

# Copy in some files we need.
cp $srcdir/../doc/texinfo.tex testSubDir || exit 1

cd ./testSubDir


# Unset the user's envvars that might change the behavior.
unset TEXI2DVI_BUILD_MODE
unset TEXI2DVI_BUILD_DIRECTORY

echo "=== Running test $0"

# POSIX no longer requires 'egrep' and 'fgrep',
# but some hosts lack 'grep -E' and 'grep -F'.
EGREP='@EGREP@'
FGREP='@FGREP@'

# The amount we should wait after modifying files depends on the platform.
# For instance, Windows '95, '98 and ME have 2-second granularity
# and can be up to 3 seconds in the future w.r.t. the system clock.
sleep='sleep @MODIFICATION_DELAY@'

# The tests call `make -e' but we do not want $srcdir from the environment
# to override the definition from the Makefile.
testsrcdir=$srcdir
unset srcdir


# create_input_texi < INPUT
# -------------------------
# Create input.texi adding stdin inside a default prologue/epilogue
create_input_texi ()
{
  {
    cat << END
\input texinfo   @c -*-texinfo-*-
@setfilename input
@settitle input

@ifnottex
@node Top
@top input
@end ifnottex

END
    cat
    cat << END
@bye
END
  } >input.texi
}


# create_input_tex < INPUT
# ------------------------
# Create input.tex adding stdin inside a default prologue/epilogue
create_input_tex ()
{
  {
    cat << END
\documentclass{article}

\begin{document}
END
    cat
    cat << END
\end{document}
END
  } >input.tex
}


# TEXI2DVI_run status [options...]
# --------------------------------
# Run texi2dvi with OPTIONS, and fail if does not exit with STATUS.
TEXI2DVI_run ()
{
  expected_exitcode=$1
  shift
  exitcode=0
  if test -n "$VERBOSE"; then
    set x --debug --verbose ${1+"$@"}
    shift
  fi
  texi2dvi ${1+"$@"} 2>stderr >stdout || exitcode=$?
  cat stderr
  cat stdout
  test $exitcode = $expected_exitcode || exit 1
}


# TEXI2DVI_fail [options...]
# ---------------------------
# Run texi2dvi with OPTIONS, and fail if does not exit with failure.
TEXI2DVI_fail ()
{
  TEXI2DVI_run 1 ${1+"$@"}
}


# TEXI2DVI_pass [options...]
# ---------------------------
# Run texi2dvi with OPTIONS, and fail if does not exit with failure.
TEXI2DVI_pass ()
{
  TEXI2DVI_run 0 ${1+"$@"}
}


# optionset_get N OPTIONSET<1> -- OPTIONSET<2> -- ...
# ---------------------------------------------------
# Return OPTIONSET<N>
optionset_get ()
{
  n=$1
  shift
  # Find the optionset.
  while test $n != 1; do
    case $1 in
      --) n=`expr $n - 1`;;
    esac
    shift
  done
  # Return the optionset.
  while true; do
    case $#:$1 in
      0:) break;;
    *:--) shift; break;;
       *) echo "$1"; shift;;
    esac
  done
}

# list_files ()
# -------------
# Return the sorted list of files in this directory, except the "invisible" ones.
list_files ()
{
  for f in *
  do
    case $f in
      texinfo.tex | stdout | stderr | ls.expected | ls.value );;
      *) echo $f;;
    esac
  done | sort
}


# assert_files (EXPECTED-FILES)
# -----------------------------
# Only those files are valid in the current directory.
assert_files ()
{
  if test -n "$VERBOSE"; then
    ls
  fi
  list_files > ls.value
  echo "$*" | tr ' ' '\n' | sort > ls.expected
  diff -u ls.expected ls.value
}


# assert_and_remove_files (EXPECTED-FILES)
# ----------------------------------------
# Only those files are valid in the current directory.  Remove them
# afterwards.
assert_and_remove_files ()
{
  assert_files "$@"
  rm -rf "$@"
}


# title TITLE...
# --------------
# Make a huge title to ease the reading of the output.
title ()
{
  (
    set +x
    echo "    $@    " | sed -e 's/./=/g'
    echo "    $@    "
    echo "    $@    " | sed -e 's/./=/g'
  )
}

# $latex_paragraph
# ----------------
# Some lengthy LaTeX.
# grep -E '^[a-zA-Z]+$' /usr/share/dict/words | sed 200q | pr --page-width=76 --column=5 --omit-header
latex_paragraph='
A              Acrux        Aegean           Ahmad          Albany
AOL            Actaeon        Aelfric        Ahmadabad      Albee
Aachen         Acton        Aeneas           Ahmed          Alberio
Aaliyah        Acts         Aeneid           Ahriman        Albert
Aaron          Acuff        Aeolus           Aida           Alberta
Abbas          Ada          Aeroflot         Aiken          Alberto
Abbasid        Adam         Aeschylus        Aileen         Albigensian
Abbott         Adams        Aesculapius    Aimee     Albion
Abby           Adan         Aesop            Ainu           Albireo
Abdul          Adana        Afghan           Airedale       Albuquerque
Abe            Adar         Afghanistan    Airedales        Alcatraz
Abel           Addams       Afghans          Aisha          Alcestis
Abelard        Adderley       Africa         Ajax           Alcibiades
Abelson        Addie        African          Akbar          Alcmena
Aberdeen       Addison        Africans       Akhmatova      Alcoa
Abernathy      Adela        Afrikaans        Akihito        Alcott
Abidjan        Adelaide       Afrikaner      Akita          Alcuin
Abigail        Adele        Afrikaners     Akkad     Alcyone
Abilene        Adeline        Afro           Akron          Aldan
Abner          Aden         Afrocentrism   Al        Aldebaran
Abraham        Adenauer       Afros          Ala     Alden
Abram          Adhara       Ag       Alabama        Alderamin
Abrams         Adidas       Agamemnon        Alabaman       Aldo
Absalom        Adirondack     Agassi         Alabamans      Aldrin
Abuja          Adirondacks    Agassiz        Alabamian      Alec
Abyssinia      Adkins       Agatha           Alabamians     Aleichem
Abyssinian     Adler        Aggie            Aladdin        Alejandra
Ac             Adolf        Aglaia           Alamo          Alejandro
Acadia         Adolfo       Agnes            Alamogordo     Alembert
Acapulco       Adolph       Agnew            Alan           Aleppo
Accra          Adonis       Agni             Alana          Aleut
Acevedo        Adonises       Agra           Alar           Aleutian
Achaean        Adrian       Agricola         Alaric         Alex
Achebe         Adriana        Agrippa        Alaska         Alexander
Achernar       Adriatic       Agrippina      Alaskan        Alexandra
Acheson        Adrienne       Aguilar        Alaskans       Alexandria
Achilles       Advent       Aguinaldo        Alba           Alexei
Aconcagua      Adventist      Aguirre        Albania        Alexis
Acosta         Advents        Agustin        Albanian       Alfonso
Acropolis      Advil        Ahab             Albanians      Alfonzo
'


# Turn on shell traces when VERBOSE is set.
if test -n "$VERBOSE"; then
  set -x
else
  :
fi
pwd