Blame gettext-tools/tests/format-ycp-1

Packit Bot 06c835
#! /bin/sh
Packit Bot 06c835
. "${srcdir=.}/init.sh"; path_prepend_ . ../src
Packit Bot 06c835
Packit Bot 06c835
# Test recognition of YCP format strings.
Packit Bot 06c835
Packit Bot 06c835
cat <<\EOF > f-y-1.data
Packit Bot 06c835
# Valid: no argument
Packit Bot 06c835
"abc%%def"
Packit Bot 06c835
# Valid: one argument
Packit Bot 06c835
"abc%1def"
Packit Bot 06c835
# Valid: nine arguments
Packit Bot 06c835
"abc%9def"
Packit Bot 06c835
# Invalid: unterminated
Packit Bot 06c835
"abc%%def%"
Packit Bot 06c835
# Invalid: non-digit
Packit Bot 06c835
"abc%%def%x"
Packit Bot 06c835
# Invalid: zero
Packit Bot 06c835
"abc%%def%0"
Packit Bot 06c835
# Valid: permutation
Packit Bot 06c835
"abc%2def%1"
Packit Bot 06c835
# Valid: multiple uses of same argument
Packit Bot 06c835
"abc%2def%1ghi%2"
Packit Bot 06c835
EOF
Packit Bot 06c835
Packit Bot 06c835
: ${XGETTEXT=xgettext}
Packit Bot 06c835
n=0
Packit Bot 06c835
while read comment; do
Packit Bot 06c835
  read string
Packit Bot 06c835
  n=`expr $n + 1`
Packit Bot 06c835
  cat <<EOF > f-y-1-$n.in
Packit Bot 06c835
_(${string});
Packit Bot 06c835
EOF
Packit Bot 06c835
  ${XGETTEXT} -L YCP -o f-y-1-$n.po f-y-1-$n.in || exit 1
Packit Bot 06c835
  test -f f-y-1-$n.po || exit 1
Packit Bot 06c835
  fail=
Packit Bot 06c835
  if echo "$comment" | grep 'Valid:' > /dev/null; then
Packit Bot 06c835
    if grep ycp-format f-y-1-$n.po > /dev/null; then
Packit Bot 06c835
      :
Packit Bot 06c835
    else
Packit Bot 06c835
      fail=yes
Packit Bot 06c835
    fi
Packit Bot 06c835
  else
Packit Bot 06c835
    if grep ycp-format f-y-1-$n.po > /dev/null; then
Packit Bot 06c835
      fail=yes
Packit Bot 06c835
    else
Packit Bot 06c835
      :
Packit Bot 06c835
    fi
Packit Bot 06c835
  fi
Packit Bot 06c835
  if test -n "$fail"; then
Packit Bot 06c835
    echo "Format string recognition error:" 1>&2
Packit Bot 06c835
    cat f-y-1-$n.in 1>&2
Packit Bot 06c835
    echo "Got:" 1>&2
Packit Bot 06c835
    cat f-y-1-$n.po 1>&2
Packit Bot 06c835
    exit 1
Packit Bot 06c835
  fi
Packit Bot 06c835
  rm -f f-y-1-$n.in f-y-1-$n.po
Packit Bot 06c835
done < f-y-1.data
Packit Bot 06c835
Packit Bot 06c835
exit 0