summaryrefslogtreecommitdiffstats
path: root/src/tests/man-recode-in-place
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:37:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 19:37:10 +0000
commitc9addba5cc770d2d231b34f6739f32c6be8690f1 (patch)
treec643da154a95a1d163137135050bb47858a1654e /src/tests/man-recode-in-place
parentInitial commit. (diff)
downloadman-db-c9addba5cc770d2d231b34f6739f32c6be8690f1.tar.xz
man-db-c9addba5cc770d2d231b34f6739f32c6be8690f1.zip
Adding upstream version 2.12.0.upstream/2.12.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tests/man-recode-in-place')
-rwxr-xr-xsrc/tests/man-recode-in-place52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/tests/man-recode-in-place b/src/tests/man-recode-in-place
new file mode 100755
index 0000000..7262a0c
--- /dev/null
+++ b/src/tests/man-recode-in-place
@@ -0,0 +1,52 @@
+#! /bin/sh
+
+# Test man-recode's --in-place behaviour.
+
+: "${srcdir=.}"
+# shellcheck source-path=SCRIPTDIR
+. "$srcdir/testlib.sh"
+
+: "${MAN_RECODE=man-recode}"
+
+init
+
+cat >"$tmpdir/a.1.exp" <<'EOF'
+.SH NAME
+a \- á
+EOF
+cp "$tmpdir/a.1.exp" "$tmpdir/a.1"
+cat >"$tmpdir/b.1.exp" <<'EOF'
+'\" -*- coding: UTF-8 -*-
+.SH NAME
+b \- é
+EOF
+gzip -c <"$tmpdir/b.1.exp" >"$tmpdir/b.1.gz"
+cat >"$tmpdir/c.1.exp" <<'EOF'
+'\" -*- coding: UTF-8
+.SH NAME
+b \- é
+EOF
+cat >"$tmpdir/c.1" <<'EOF'
+'\" -*- coding: ISO-8859-1
+EOF
+<"$tmpdir/c.1.exp" tail -n +2 | iconv -f UTF-8 -t ISO-8859-1 >>"$tmpdir/c.1"
+gzip "$tmpdir/c.1"
+
+run $MAN_RECODE -t UTF-8 --in-place \
+ "$tmpdir/a.1" "$tmpdir/b.1.gz" "$tmpdir/c.1.gz"
+expect_files_equal '--in-place with no coding tag' \
+ "$tmpdir/a.1.exp" "$tmpdir/a.1"
+if [ "$HAVE_ICONV" = yes ]; then
+ expect_files_equal '--in-place with gzip and coding tag matching target encoding' \
+ "$tmpdir/b.1.exp" "$tmpdir/b.1"
+ expect_files_equal \
+ '--in-place with gzip and coding tag not matching target encoding' \
+ "$tmpdir/c.1.exp" "$tmpdir/c.1"
+else
+ report_skip '--in-place with gzip and coding tag matching target encoding'
+ report_skip '--in-place with gzip and coding tag not matching target encoding'
+fi
+test ! -f "$tmpdir/b.1.gz" && test ! -f "$tmpdir/c.1.gz"
+report '--in-place removes compressed input files' "$?"
+
+finish