summaryrefslogtreecommitdiffstats
path: root/src/tests/manconv-guess-from-encoding
blob: ca6f0bd0c6404d312a8f0b8cf83ad9be978d50bd (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
#! /bin/sh

# Test manconv's support for guessing the input encoding if it is not
# explicitly specified.

: "${srcdir=.}"
# shellcheck source-path=SCRIPTDIR
. "$srcdir/testlib.sh"

: "${MANCONV=manconv}"

init

if [ "$HAVE_ICONV" != yes ]; then
	skip 'encoding conversion requires a working iconv'
fi

write_page coding-tag 7 \
	"$tmpdir/usr/share/man/man7/coding-tag.7" \
	ISO-8859-1 '' '' 'coding-tag \- é'
iconv -f ISO-8859-1 -t UTF-8 \
	<"$tmpdir/usr/share/man/man7/coding-tag.7" \
	>"$tmpdir/coding-tag.7.exp"
run $MANCONV -t UTF-8 "$tmpdir/usr/share/man/man7/coding-tag.7" \
	>"$tmpdir/coding-tag.7.out"
expect_files_equal 'recode from encoding guessed from directory name' \
	"$tmpdir/coding-tag.7.exp" "$tmpdir/coding-tag.7.out"

write_page lang-dir 7 \
	"$tmpdir/usr/share/man/fr_FR.ISO-8859-1/man7/lang-dir.7.gz" \
	ISO-8859-1 gz '-*- coding: ISO-8859-1 -*-' 'lang-dir \- é'
cat >"$tmpdir/lang-dir.7.exp" <<'EOF'
'\" -*- coding: UTF-8 -*-
EOF
zcat "$tmpdir/usr/share/man/fr_FR.ISO-8859-1/man7/lang-dir.7.gz" | \
	tail -n +2 | iconv -f ISO-8859-1 -t UTF-8 >>"$tmpdir/lang-dir.7.exp"
run $MANCONV -t UTF-8 \
	"$tmpdir/usr/share/man/fr_FR.ISO-8859-1/man7/lang-dir.7.gz" \
	>"$tmpdir/lang-dir.7.out"
expect_files_equal 'recode from encoding guessed from directory name' \
	"$tmpdir/lang-dir.7.exp" "$tmpdir/lang-dir.7.out"

finish