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