| 1 |
#! /bin/sh -vx |
| 2 |
# |
| 3 |
# Copyright 2022-2025 Japanese TeX Development Community <[email protected]> |
| 4 |
# You may freely use, modify and/or distribute this file. |
| 5 |
|
| 6 |
engine=uptex |
| 7 |
testdir=up0tests |
| 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=; err3=; err4= |
| 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 |
try_ienc="sjis" |
| 50 |
else |
| 51 |
echo "*** We guess OS is not Windows." |
| 52 |
MyOS=nonWindows |
| 53 |
try_ienc="euc sjis" |
| 54 |
fi |
| 55 |
if [ "$ExeExt" = ".exe" ]; then |
| 56 |
opt_win=-windows |
| 57 |
else |
| 58 |
opt_win= |
| 59 |
fi |
| 60 |
|
| 61 |
perl -s $srcdir/tests/fn-generate.perl $opt_win $testdir |
| 62 |
pret=$? |
| 63 |
if [ $pret != 0 ] && [ $pret != 239 ]; then |
| 64 |
exit 77 |
| 65 |
fi |
| 66 |
|
| 67 |
# upTeX internal encoding |
| 68 |
fenc="utf8" |
| 69 |
for ienc in $try_ienc; do |
| 70 |
for doc in fn-$fenc fnさざ波-$fenc; do |
| 71 |
|
| 72 |
if [ $MyOS = Windows ]; then |
| 73 |
command_line_encoding=none |
| 74 |
export command_line_encoding |
| 75 |
fi |
| 76 |
|
| 77 |
echo '>>> Document:'$doc ' File Encoding:'$fenc ' Internal Encoding:'$ienc |
| 78 |
job=$doc-$ienc-up0 |
| 79 |
$_kpsewhich -progname=$engine $doc.tex || rc=10 |
| 80 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8.tex || rc=11 |
| 81 |
rm -f $testdir/$doc-tmp.tex $testdir/$job.txt $testdir/$job.log |
| 82 |
$_tex -ini -interaction nonstopmode -jobname=$job -kanji=$fenc --kanji-internal=$ienc --shell-escape --recorder $doc.tex >$testdir/$doc-$fenc-$ienc-term.log || \ |
| 83 |
{ rc=1 ; err1=$err1" $fenc:$ienc:$doc" ; } |
| 84 |
$_kpsewhich -progname=$engine $doc-tmp.tex || rc=12 |
| 85 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8-tmp.tex || rc=13 |
| 86 |
mv $job.txt $job.log $testdir/ || rc=14 |
| 87 |
mv $job.fls $testdir/ || rc=15 |
| 88 |
diff $testdir/$job.txt $srcdir/tests/fn-$fenc.txt || \ |
| 89 |
{ rc=2 ; err2=$err2" $fenc:$ienc:$doc" ; } |
| 90 |
rm -f $testdir/fn±×÷§¶-utf8-tmp.tex |
| 91 |
|
| 92 |
done |
| 93 |
done |
| 94 |
|
| 95 |
if [ $pret = 239 ]; then |
| 96 |
echo "*** skip tests for Shift_JIS & EUC-JP." |
| 97 |
exit 0 |
| 98 |
fi |
| 99 |
|
| 100 |
|
| 101 |
# pTeX compatible mode, regacy encoding |
| 102 |
for fenc in sjis euc; do |
| 103 |
for doc in fnさざ波-$fenc; do |
| 104 |
|
| 105 |
ienc=$fenc |
| 106 |
if [ $MyOS = Windows ]; then |
| 107 |
ienc="sjis" |
| 108 |
command_line_encoding=none |
| 109 |
export command_line_encoding |
| 110 |
else |
| 111 |
if [ $fenc != sjis ]; then ienc="euc"; fi |
| 112 |
fi |
| 113 |
guess_input_kanji_encoding=1 |
| 114 |
export guess_input_kanji_encoding |
| 115 |
|
| 116 |
echo '>>> Document:'$doc ' File Encoding:'$fenc ' Internal Encoding:'$ienc |
| 117 |
job=$doc-$ienc-up0 |
| 118 |
$_kpsewhich -progname=$engine $doc.tex || rc=20 |
| 119 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8.tex || rc=21 |
| 120 |
rm -f $testdir/$doc-tmp.tex $testdir/$job.txt $testdir/$job.log |
| 121 |
$_tex -ini -interaction nonstopmode -jobname=$job -kanji=$fenc --kanji-internal=$ienc --shell-escape --recorder $doc.tex >$testdir/$doc-$fenc-$ienc-term.log || \ |
| 122 |
{ rc=3 ; err3=$err3" $fenc:$ienc:$doc" ; } |
| 123 |
$_kpsewhich -progname=$engine $doc-tmp.tex || rc=22 |
| 124 |
$_kpsewhich -progname=$engine fn±×÷§¶-utf8-tmp.tex || rc=23 |
| 125 |
mv $job.txt $job.log $testdir/ || rc=24 |
| 126 |
mv $job.fls $testdir/ || rc=25 |
| 127 |
diff $testdir/$job.txt $srcdir/tests/fn-$fenc.txt || \ |
| 128 |
{ rc=4 ; err4=$err4" $fenc:$ienc:$doc" ; } |
| 129 |
|
| 130 |
done |
| 131 |
done |
| 132 |
|
| 133 |
|
| 134 |
if [ $rc -gt 0 ]; then |
| 135 |
if [ -n "$err1" ]; then echo ERROR1 $err1; fi |
| 136 |
if [ -n "$err2" ]; then echo ERROR2 $err2; fi |
| 137 |
if [ -n "$err3" ]; then echo ERROR3 $err3; fi |
| 138 |
if [ -n "$err4" ]; then echo ERROR4 $err4; fi |
| 139 |
else |
| 140 |
echo PASS |
| 141 |
fi |
| 142 |
exit $rc |