[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[bug-gettext] [PATCH 3/3] Tests for python-brace-format.
From: |
Daiki Ueno |
Subject: |
[bug-gettext] [PATCH 3/3] Tests for python-brace-format. |
Date: |
Fri, 14 Dec 2012 17:47:44 +0900 |
---
gettext-tools/tests/ChangeLog | 5 +++
gettext-tools/tests/Makefile.am | 4 +--
.../{format-perl-brace-1 => format-python-brace-1} | 34 ++++++++----------
gettext-tools/tests/xgettext-python-5 | 41 ++++++++++++++++++++++
4 files changed, 63 insertions(+), 21 deletions(-)
copy gettext-tools/tests/{format-perl-brace-1 => format-python-brace-1} (53%)
mode change 100755 => 100644
create mode 100644 gettext-tools/tests/xgettext-python-5
diff --git a/gettext-tools/tests/ChangeLog b/gettext-tools/tests/ChangeLog
index 0cc1edc..0d2d6da 100644
--- a/gettext-tools/tests/ChangeLog
+++ b/gettext-tools/tests/ChangeLog
@@ -1,3 +1,8 @@
+2012-12-14 Daiki Ueno <address@hidden>
+
+ * format-python-brace-1: New test.
+ * xgettext-python-5: New test.
+
2012-06-03 Jim Meyering <address@hidden>
* msgcomm-17: Spelling fixes.
diff --git a/gettext-tools/tests/Makefile.am b/gettext-tools/tests/Makefile.am
index f875913..d07e460 100644
--- a/gettext-tools/tests/Makefile.am
+++ b/gettext-tools/tests/Makefile.am
@@ -91,7 +91,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5
gettext-6 gettext-7 \
xgettext-po-1 \
xgettext-properties-1 \
xgettext-python-1 xgettext-python-2 xgettext-python-3 \
- xgettext-python-4 \
+ xgettext-python-4 xgettext-python-5 \
xgettext-scheme-1 xgettext-scheme-2 xgettext-scheme-3 \
xgettext-sh-1 xgettext-sh-2 xgettext-sh-3 xgettext-sh-4 xgettext-sh-5 \
xgettext-sh-6 \
@@ -111,7 +111,7 @@ TESTS = gettext-1 gettext-2 gettext-3 gettext-4 gettext-5
gettext-6 gettext-7 \
format-librep-1 format-librep-2 \
format-lisp-1 format-lisp-2 \
format-php-1 format-php-2 \
- format-python-1 format-python-2 \
+ format-python-1 format-python-2 format-python-brace-1 \
format-pascal-1 format-pascal-2 \
format-perl-1 format-perl-2 \
format-perl-brace-1 format-perl-brace-2 \
diff --git a/gettext-tools/tests/format-perl-brace-1
b/gettext-tools/tests/format-python-brace-1
old mode 100755
new mode 100644
similarity index 53%
copy from gettext-tools/tests/format-perl-brace-1
copy to gettext-tools/tests/format-python-brace-1
index e78266f..a79e74d
--- a/gettext-tools/tests/format-perl-brace-1
+++ b/gettext-tools/tests/format-python-brace-1
@@ -1,16 +1,18 @@
#! /bin/sh
-# Test recognition of Perl brace format strings.
+# Test recognition of Python brace format strings.
tmpfiles=""
trap 'rm -fr $tmpfiles' 1 2 3 15
-tmpfiles="$tmpfiles f-pb-1.data"
-cat <<\EOF > f-pb-1.data
+tmpfiles="$tmpfiles f-pyb-1.data"
+cat <<\EOF > f-pyb-1.data
# Invalid: no argument
"abc"
# Valid: a named argument
"abc{value}"
+# Valid: a number argument
+"abc{0}"
# Invalid: an empty name
"abc{}"
# Invalid: unterminated name
@@ -21,12 +23,6 @@ cat <<\EOF > f-pb-1.data
"{foo bar}"
# Invalid: missing right angle bracket.
"{foo bar"
-# Valid: not nested, but one single place-holder.
-"{foo{bar}baz}"
-# Valid: no nesting error, but one single place-holder.
-"{foo{bar}baz"
-# Valid: place-holder with spaces must be ignored, but still one remaining.
-"{foo bar} {baz}"
# Invalid: percent sign not allowed.
"{foo%bar}"
EOF
@@ -36,21 +32,21 @@ n=0
while read comment; do
read string
n=`expr $n + 1`
- tmpfiles="$tmpfiles f-pb-1-$n.in f-pb-1-$n.po"
- cat <<EOF > f-pb-1-$n.in
+ tmpfiles="$tmpfiles f-pyb-1-$n.in f-pyb-1-$n.po"
+ cat <<EOF > f-pyb-1-$n.in
gettext(${string});
EOF
- ${XGETTEXT} -L Perl -o f-pb-1-$n.po f-pb-1-$n.in || exit 1
- test -f f-pb-1-$n.po || exit 1
+ ${XGETTEXT} -L Python -o f-pyb-1-$n.po f-pyb-1-$n.in || exit 1
+ test -f f-pyb-1-$n.po || exit 1
fail=
if echo "$comment" | grep 'Valid:' > /dev/null; then
- if grep perl-brace-format f-pb-1-$n.po > /dev/null; then
+ if grep python-brace-format f-pyb-1-$n.po > /dev/null; then
:
else
fail=yes
fi
else
- if grep perl-brace-format f-pb-1-$n.po > /dev/null; then
+ if grep python-brace-format f-pyb-1-$n.po > /dev/null; then
fail=yes
else
:
@@ -58,13 +54,13 @@ EOF
fi
if test -n "$fail"; then
echo "Format string recognition error:" 1>&2
- cat f-pb-1-$n.in 1>&2
+ cat f-pyb-1-$n.in 1>&2
echo "Got:" 1>&2
- cat f-pb-1-$n.po 1>&2
+ cat f-pyb-1-$n.po 1>&2
exit 1
fi
- rm -f f-pb-1-$n.in f-pb-1-$n.po
-done < f-pb-1.data
+ rm -f f-pyb-1-$n.in f-pyb-1-$n.po
+done < f-pyb-1.data
rm -fr $tmpfiles
diff --git a/gettext-tools/tests/xgettext-python-5
b/gettext-tools/tests/xgettext-python-5
new file mode 100644
index 0000000..d56d87a
--- /dev/null
+++ b/gettext-tools/tests/xgettext-python-5
@@ -0,0 +1,41 @@
+#!/bin/sh
+
+# Test Python support: recognition of format strings
+
+tmpfiles=""
+trap 'rm -fr $tmpfiles' 1 2 3 15
+
+tmpfiles="$tmpfiles xg-py-5.py"
+cat <<\EOF > xg-py-5.py
+# Recognition of format strings.
+_("This is {only} a brace formatstring.").format(only = "only")
+_("This is %s." % "a format");
+EOF
+
+tmpfiles="$tmpfiles xg-py-5.tmp.po xg-py-5.po"
+: ${XGETTEXT=xgettext}
+${XGETTEXT} --add-comments --omit-header --no-location --keyword=_ \
+ -d xg-py-5.tmp xg-py-5.py
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+LC_ALL=C tr -d '\r' < xg-py-5.tmp.po > xg-py-5.po
+test $? = 0 || { rm -fr $tmpfiles; exit 1; }
+
+tmpfiles="$tmpfiles xg-py-5.ok"
+cat <<EOF > xg-py-5.ok
+#. Recognition of format strings.
+#, python-brace-format
+msgid "This is {only} a brace formatstring."
+msgstr ""
+
+#, python-format
+msgid "This is %s."
+msgstr ""
+EOF
+
+: ${DIFF=diff}
+${DIFF} xg-py-5.ok xg-py-5.po
+result=$?
+
+rm -fr $tmpfiles
+
+exit $result
--
1.7.11.7