From: Bruno Haible Date: Sun, 13 Oct 2024 18:58:37 +0000 (+0200) Subject: tests: Add more unit tests regarding Desktop files. X-Git-Tag: v0.23~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=800d9b8794409477f5651a1c9062a55414d23770;p=thirdparty%2Fgettext.git tests: Add more unit tests regarding Desktop files. Reported by Felix Riemann at and by Daniel at . * gettext-tools/tests/xgettext-desktop-3: New file. * gettext-tools/tests/msgfmt-desktop-4: New file. * gettext-tools/tests/Makefile.am (TESTS): Add them. --- diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am index b782aaa95..ae4efd9ff 100644 --- a/gettext-tools/tests/Makefile.am +++ b/gettext-tools/tests/Makefile.am @@ -56,7 +56,7 @@ TESTS = gettext-1 gettext-2 \ msgfmt-properties-1 \ msgfmt-tcl-1 msgfmt-tcl-2 \ msgfmt-qt-1 msgfmt-qt-2 \ - msgfmt-desktop-1 msgfmt-desktop-2 msgfmt-desktop-3 \ + msgfmt-desktop-1 msgfmt-desktop-2 msgfmt-desktop-3 msgfmt-desktop-4 \ msgfmt-xml-1 msgfmt-xml-2 msgfmt-xml-3 msgfmt-xml-4 msgfmt-xml-5 \ msggrep-1 msggrep-2 msggrep-3 msggrep-4 msggrep-5 msggrep-6 msggrep-7 \ msggrep-8 msggrep-9 msggrep-10 msggrep-11 \ @@ -105,7 +105,7 @@ TESTS = gettext-1 gettext-2 \ xgettext-csharp-7 xgettext-csharp-8 xgettext-csharp-9 \ xgettext-csharp-stackovfl-1 xgettext-csharp-stackovfl-2 \ xgettext-csharp-stackovfl-3 xgettext-csharp-stackovfl-4 \ - xgettext-desktop-1 xgettext-desktop-2 \ + xgettext-desktop-1 xgettext-desktop-2 xgettext-desktop-3 \ xgettext-docbook-1 \ xgettext-elisp-1 xgettext-elisp-2 xgettext-elisp-3 \ xgettext-elisp-stackovfl-1 xgettext-elisp-stackovfl-2 \ diff --git a/gettext-tools/tests/msgfmt-desktop-4 b/gettext-tools/tests/msgfmt-desktop-4 new file mode 100755 index 000000000..8fe68f762 --- /dev/null +++ b/gettext-tools/tests/msgfmt-desktop-4 @@ -0,0 +1,93 @@ +#!/bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test of *.desktop files with non-default keywords (used by KDE). + +cat <<\EOF > hello.desktop +[Desktop Entry] +Name=Hello +Description=A friendly greeting program +TryExec=hello +Exec=hello +Icon=handshake.jpg +Type=Application +Keywords=Utility; +EOF + +cat <<\EOF > th.po +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2019-08-18 12:45+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: Thai \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: hello.desktop:2 +msgid "Hello" +msgstr "สวัสดี" + +#: hello.desktop:3 +msgid "A friendly greeting program" +msgstr "โปรแกรมทักทายแบบเป็นกันเอง" + +#: hello.desktop:8 +msgid "Utility;" +msgstr "ประโยชน์;" +EOF + +# Generate the merged .desktop file. + +: ${MSGFMT=msgfmt} +${MSGFMT} --desktop --keyword=Description \ + --template=hello.desktop -l th th.po -o hello.desktop-1.tmp \ + || Exit 1 +LC_ALL=C tr -d '\r' < hello.desktop-1.tmp > hello.desktop-1.out || Exit 1 + +: ${MSGFMT=msgfmt} +${MSGFMT} --desktop --keyword= --keyword=Description \ + --template=hello.desktop -l th th.po -o hello.desktop-2.tmp \ + || Exit 1 +LC_ALL=C tr -d '\r' < hello.desktop-2.tmp > hello.desktop-2.out || Exit 1 + +cat <<\EOF > hello.desktop-1.ok +[Desktop Entry] +Name[th]=สวัสดี +Name=Hello +Description[th]=โปรแกรมทักทายแบบเป็นกันเอง +Description=A friendly greeting program +TryExec=hello +Exec=hello +Icon=handshake.jpg +Type=Application +Keywords[th]=ประโยชน์; +Keywords=Utility; +EOF + +cat <<\EOF > hello.desktop-2.ok +[Desktop Entry] +Name=Hello +Description[th]=โปรแกรมทักทายแบบเป็นกันเอง +Description=A friendly greeting program +TryExec=hello +Exec=hello +Icon=handshake.jpg +Type=Application +Keywords=Utility; +EOF + +: ${DIFF=diff} +${DIFF} hello.desktop-1.ok hello.desktop-1.out || Exit 1 + +: ${DIFF=diff} +${DIFF} hello.desktop-2.ok hello.desktop-2.out || Exit 1 diff --git a/gettext-tools/tests/xgettext-desktop-3 b/gettext-tools/tests/xgettext-desktop-3 new file mode 100755 index 000000000..792250286 --- /dev/null +++ b/gettext-tools/tests/xgettext-desktop-3 @@ -0,0 +1,85 @@ +#!/bin/sh +. "${srcdir=.}/init.sh"; path_prepend_ . ../src + +# Test of *.desktop files with non-default keywords (used by KDE). + +cat <<\EOF > hello.desktop +[Desktop Entry] +Name=Hello +Description=A friendly greeting program +TryExec=hello +Exec=hello +Icon=handshake.jpg +Type=Application +Keywords=Utility; +EOF + +: ${XGETTEXT=xgettext} + +${XGETTEXT} --keyword=Description -o xg-de-3-1.tmp hello.desktop || Exit 1 +func_filter_POT_Creation_Date xg-de-3-1.tmp hello-desktop-1.pot + +${XGETTEXT} --keyword= --keyword=Description -o xg-de-3-2.tmp hello.desktop || Exit 1 +func_filter_POT_Creation_Date xg-de-3-2.tmp hello-desktop-2.pot + +cat <<\EOF > hello-desktop-1.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: hello.desktop:2 +msgid "Hello" +msgstr "" + +#: hello.desktop:3 +msgid "A friendly greeting program" +msgstr "" + +#: hello.desktop:8 +msgid "Utility;" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} hello-desktop-1.ok hello-desktop-1.pot || Exit 1 + +cat <<\EOF > hello-desktop-2.ok +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: hello.desktop:3 +msgid "A friendly greeting program" +msgstr "" +EOF + +: ${DIFF=diff} +${DIFF} hello-desktop-2.ok hello-desktop-2.pot || Exit 1