| 1 |
#! /bin/sh -vx |
| 2 |
# |
| 3 |
# Copyright 2022-2023 Japanese TeX Development Community <[email protected]> |
| 4 |
# You may freely use, modify and/or distribute this file. |
| 5 |
|
| 6 |
engine=uptex |
| 7 |
testdir=uptests |
| 8 |
|
| 9 |
KpsDir=${KpsDir:-../kpathsea} |
| 10 |
BinDir=${BinDir:-.} |
| 11 |
ExeExt=${ExeExt:-} |
| 12 |
_kpsewhich=$KpsDir/kpsewhich$ExeExt |
| 13 |
_tex=$BinDir/$engine$ExeExt |
| 14 |
|
| 15 |
test -d $testdir || mkdir -p $testdir |
| 16 |
rm -f $testdir/fn*.log $testdir/fn*.txt $testdir/fn*-tmp*.tex |
| 17 |
|
| 18 |
rc=0; err1=; err2= |
| 19 |
|
| 20 |
TEXMFCNF=$srcdir/../kpathsea; export TEXMFCNF |
| 21 |
TEXINPUTS="$testdir;."; export TEXINPUTS |
| 22 |
|
| 23 |
$_kpsewhich -var-value=TEXMFCNF |
| 24 |
$_kpsewhich -progname=$engine -var-value=TEXINPUTS |
| 25 |
$_kpsewhich -progname=$engine -var-value=command_line_encoding |
| 26 |
$_kpsewhich -progname=$engine -var-value=guess_input_kanji_encoding |
| 27 |
|
| 28 |
for loc in C.UTF-8 C.utf8 en_US.UTF-8 en_US.utf8 ja_JP.UTF-8 ja_JP.utf8; do |
| 29 |
locale -a | grep "^$loc\$" |
| 30 |
ret=$? |
| 31 |
# For Slackware linux, we need to replace from utf8 to UTF-8 |
| 32 |
if [ -f /etc/slackware-version ]; then |
| 33 |
loc=`echo $loc | sed -e "s/utf8/UTF-8/"` |
| 34 |
fi |
| 35 |
if [ $ret = 0 ]; then |
| 36 |
LC_ALL=$loc; LANGUAGE=$loc; export LC_ALL LANGUAGE |
| 37 |
break |
| 38 |
fi |
| 39 |
done |
| 40 |
if [ $ret != 0 ]; then |
| 41 |
# linux musl fails to run `locale -a` but seems to have C.UTF-8 |
| 42 |
loc=C.UTF-8 |
| 43 |
LC_ALL=$loc; LANGUAGE=$loc; export LC_ALL LANGUAGE |
| 44 |
fi |
| 45 |
|
| 46 |
if [ "$COMSPEC" != "" ] || [ "$ExeExt" = ".exe" ]; then |
| 47 |
echo "*** We guess OS is Windows." |
| 48 |
MyOS=Windows |
| 49 |
else |
| 50 |
echo "*** We guess OS is not Windows." |
| 51 |
MyOS=nonWindows |
| 52 |
fi |
| 53 |
if [ "$ExeExt" = ".exe" ]; then |
| 54 |
opt_win=-windows |
| 55 |
else |
| 56 |
opt_win= |
| 57 |
fi |
| 58 |
|
| 59 |
perl -s $srcdir/tests/fn-generate.perl $opt_win $testdir |
| 60 |
pret=$? |
| 61 |
if [ $pret != 0 ] && [ $pret != 239 ]; then |
| 62 |
exit 77 |
| 63 |
fi |
| 64 |
|
| 65 |
# upTeX internal encoding |
| 66 |
fenc="utf8" |
| 67 |
for ienc in uptex; do |
| 68 |
for doc in fn-$fenc fnさざ波-$fenc fn£¥µÆÇñß-$fenc fnΔДदダ打다𝕯🎉-$fenc; do |
| 69 |
|
| 70 |
if [ $ienc != uptex -a \( $doc = fn£¥µÆÇñß-$fenc -o $doc = fnΔДदダ打다𝕯🎉-$fenc \) ]; then |
| 71 |
continue |
| 72 |
fi |
| 73 |
|
| 74 |
if [ $MyOS = Windows ]; then |
| 75 |
if [ $ienc = uptex ]; then |
| 76 |
command_line_encoding=utf8 |
| 77 |
export command_line_encoding |
| 78 |
else |
| 79 |
command_line_encoding=none |
| 80 |
export command_line_encoding |
| 81 |
fi |
| 82 |
fi |
| 83 |
|
| 84 |
echo '>>> Document:'$doc ' File Encoding:'$fenc ' Internal Encoding:'$ienc |
| 85 |
job=$doc-$ienc-up |
| 86 |
$_kpsewhich -progname=$engine $doc.tex || rc=10 |
| 87 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8.tex || rc=11 |
| 88 |
rm -f $testdir/$doc-tmp.tex $testdir/$job.txt $testdir/$job.log $testdir/$job.fls |
| 89 |
$_tex -ini -interaction nonstopmode -jobname=$job -kanji=$fenc --kanji-internal=$ienc --shell-escape --recorder $doc.tex >$testdir/$doc-$fenc-$ienc-term.log || \ |
| 90 |
{ rc=1 ; err1=$err1" $fenc:$ienc:$doc" ; } |
| 91 |
$_kpsewhich -progname=$engine $doc-tmp.tex || rc=12 |
| 92 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8-tmp.tex || rc=13 |
| 93 |
mv $job.txt $job.log $job.fls $testdir/ || rc=14 |
| 94 |
diff $testdir/$job.txt $srcdir/tests/fn-$fenc.txt || \ |
| 95 |
{ rc=2 ; err2=$err2" $fenc:$ienc:$doc" ; } |
| 96 |
|
| 97 |
done |
| 98 |
done |
| 99 |
|
| 100 |
|
| 101 |
if [ $rc -gt 0 ]; then |
| 102 |
if [ -n "$err1" ]; then echo ERROR1 $err1; fi |
| 103 |
if [ -n "$err2" ]; then echo ERROR2 $err2; fi |
| 104 |
else |
| 105 |
echo PASS |
| 106 |
fi |
| 107 |
exit $rc |