Home | History | Annotate | Line # | Download | only in tests
format-qt-1 revision 1.1
      1 #! /bin/sh
      2 
      3 # Test recognition of Qt format strings.
      4 
      5 tmpfiles=""
      6 trap 'rm -fr $tmpfiles' 1 2 3 15
      7 
      8 tmpfiles="$tmpfiles f-qt-1.data"
      9 cat <<\EOF > f-qt-1.data
     10 # Unrecognized: no argument
     11 "abc%%def"
     12 # Valid: one argument
     13 "abc%1def"
     14 # Valid: one argument
     15 "abc%9def"
     16 # Valid: unterminated
     17 "abc%1def%"
     18 # Valid: non-digit
     19 "abc%1def%x"
     20 # Valid: zero
     21 "abc%1def%0"
     22 # Valid: permutation
     23 "abc%2def%1"
     24 # Invalid: multiple uses of same argument
     25 "abc%2def%1ghi%2"
     26 EOF
     27 
     28 : ${XGETTEXT=xgettext}
     29 n=0
     30 while read comment; do
     31   read string
     32   n=`expr $n + 1`
     33   tmpfiles="$tmpfiles f-qt-1-$n.in f-qt-1-$n.po"
     34   cat <<EOF > f-qt-1-$n.in
     35 _(${string});
     36 EOF
     37   ${XGETTEXT} -L C++ --qt -k_ -o f-qt-1-$n.po f-qt-1-$n.in || exit 1
     38   test -f f-qt-1-$n.po || exit 1
     39   fail=
     40   if echo "$comment" | grep 'Valid:' > /dev/null; then
     41     if grep qt-format f-qt-1-$n.po > /dev/null; then
     42       :
     43     else
     44       fail=yes
     45     fi
     46   else
     47     if grep qt-format f-qt-1-$n.po > /dev/null; then
     48       fail=yes
     49     else
     50       :
     51     fi
     52   fi
     53   if test -n "$fail"; then
     54     echo "Format string recognition error:" 1>&2
     55     cat f-qt-1-$n.in 1>&2
     56     echo "Got:" 1>&2
     57     cat f-qt-1-$n.po 1>&2
     58     exit 1
     59   fi
     60   rm -f f-qt-1-$n.in f-qt-1-$n.po
     61 done < f-qt-1.data
     62 
     63 rm -fr $tmpfiles
     64 
     65 exit 0
     66