| 1 |
#! /bin/sh -vx |
| 2 |
# qqq also check propagated to subprog |
| 3 |
# $Id: outputdir.test 68508 2023-10-10 22:01:41Z karl $ |
| 4 |
# outputdir.test - check that TEXMF_OUTPUT_DIRECTORY works. |
| 5 |
# Public domain. Originally written by Karl Berry, 2023. |
| 6 |
|
| 7 |
BinDir=${BinDir:-..} # ordinarily run from the web2c/tests subdir in build |
| 8 |
ExeExt=${ExeExt:-} |
| 9 |
|
| 10 |
# in case we're invoked standalone instead of from make. |
| 11 |
test -z "$srcdir" && srcdir=`cd \`dirname $0\`/.. && pwd` # web2c/ |
| 12 |
TEXMFCNF=$srcdir/../kpathsea; export TEXMFCNF |
| 13 |
|
| 14 |
( |
| 15 |
# We have to cd so we can make an output directory |
| 16 |
# that would normally be disallowed. |
| 17 |
cd tests || exit 1 |
| 18 |
pwd |
| 19 |
|
| 20 |
outdir=../outdirtest |
| 21 |
TEXMF_OUTPUT_DIRECTORY=$outdir; export TEXMF_OUTPUT_DIRECTORY |
| 22 |
|
| 23 |
outfile=outfile.tex |
| 24 |
rm -rf $outdir $outfile # don't let previous runs interfere |
| 25 |
mkdir $outdir || exit 1 |
| 26 |
|
| 27 |
for engine in tex; do # luatex mpost |
| 28 |
_engine=$BinDir/$engine$ExeExt |
| 29 |
|
| 30 |
# The output file should be written to outdir (not .), because of the |
| 31 |
# envvar. Ordinarily a .. path would be rejected for writing. |
| 32 |
$_engine -ini '\immediate\openout1='$outfile'\end' || exit 3 |
| 33 |
|
| 34 |
set -x |
| 35 |
ls -l $outdir/$outfile || exit 5 # ensure it got written, |
| 36 |
ls -l $outfile && exit 7 # and not to cwd. |
| 37 |
|
| 38 |
# Then we should be able to read it back in TeX, implicitly from outdir. |
| 39 |
$_engine -ini '\input '$outfile' \end' || exit 9 |
| 40 |
|
| 41 |
# The log file should also have been written to outdir. |
| 42 |
ls -l $outdir/`basename $outfile .tex`.log || exit 11 |
| 43 |
done |
| 44 |
|
| 45 |
) # end subshell in tests subdir |
| 46 |
exit $? # must be the next line to propagate status |
| 47 |
|
| 48 |
# We could test that it propagates to subprograms with something like |
| 49 |
# tex -ini --shell-restricted '\catcode123=1 \catcode125=2 \immediate\write18{kpsewhich --var-value TEXMF_OUTPUT_DIRECTORY}\end' |
| 50 |
# but since it requires so much config file stuff, let's not bother. |
| 51 |
|
| 52 |
# In theory we should run this with all the tex engines + mf, |
| 53 |
# but it just doesn't seem worth the time or trouble. After it's |
| 54 |
# implemented in LuaTeX and MetaPost, would be worth it there since it's |
| 55 |
# independent code. |
| 56 |
|
| 57 |
# BibTeX requires implementing the output directory stuff; see bibtex.ch. |
| 58 |
# If that's ever done, a test invocation, within the subshell above, |
| 59 |
# could look like: |
| 60 |
# TEXMFCNF=$srcdir/../kpathsea \ |
| 61 |
# BSTINPUTS=$srcdir/tests \ |
| 62 |
# BIBINPUTS=$srcdir/tests \ |
| 63 |
# $_bibtex $srcdir/tests/exampl.aux || exit 1 |