Home | History | Annotate | Line # | Download | only in tests
      1  1.1  christos #! /bin/sh
      2  1.1  christos 
      3  1.1  christos # Test of gettext facilities in the RST format.
      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 prog.rst"
      9  1.1  christos cat <<\EOF > prog.rst
     10  1.1  christos # From the rstconv program itself.
     11  1.1  christos rstconv.help='rstconv [-h|--help]    Displays this help'#10+
     12  1.1  christos 'rstconv options        Convert rst file'#10#10+
     13  1.1  christos 'Options are:'#10+
     14  1.1  christos '  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)'#10+
     15  1.1  christos '  -o file    Write output to specified file (REQUIRED)'#10+
     16  1.1  christos '  -f format  Specifies the output format:'#10+
     17  1.1  christos '             po    GNU gettext .po (portable) format (DEFAULT)'#10
     18  1.1  christos 
     19  1.1  christos rstconv.InvalidOption='Invalid option - '
     20  1.1  christos rstconv.OptionAlreadySpecified='Option has already been specified - '
     21  1.1  christos rstconv.NoOutFilename='No output filename specified'
     22  1.1  christos rstconv.InvalidOutputFormat='Invalid output format -'
     23  1.1  christos EOF
     24  1.1  christos 
     25  1.1  christos tmpfiles="$tmpfiles prog.pot"
     26  1.1  christos : ${XGETTEXT=xgettext}
     27  1.1  christos ${XGETTEXT} -o prog.pot --omit-header --add-location prog.rst
     28  1.1  christos 
     29  1.1  christos tmpfiles="$tmpfiles prog.ok"
     30  1.1  christos cat <<EOF > prog.ok
     31  1.1  christos #: rstconv.help
     32  1.1  christos msgid ""
     33  1.1  christos "rstconv [-h|--help]    Displays this help\n"
     34  1.1  christos "rstconv options        Convert rst file\n"
     35  1.1  christos "\n"
     36  1.1  christos "Options are:\n"
     37  1.1  christos "  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n"
     38  1.1  christos "  -o file    Write output to specified file (REQUIRED)\n"
     39  1.1  christos "  -f format  Specifies the output format:\n"
     40  1.1  christos "             po    GNU gettext .po (portable) format (DEFAULT)\n"
     41  1.1  christos msgstr ""
     42  1.1  christos 
     43  1.1  christos #: rstconv.InvalidOption
     44  1.1  christos msgid "Invalid option - "
     45  1.1  christos msgstr ""
     46  1.1  christos 
     47  1.1  christos #: rstconv.OptionAlreadySpecified
     48  1.1  christos msgid "Option has already been specified - "
     49  1.1  christos msgstr ""
     50  1.1  christos 
     51  1.1  christos #: rstconv.NoOutFilename
     52  1.1  christos msgid "No output filename specified"
     53  1.1  christos msgstr ""
     54  1.1  christos 
     55  1.1  christos #: rstconv.InvalidOutputFormat
     56  1.1  christos msgid "Invalid output format -"
     57  1.1  christos msgstr ""
     58  1.1  christos EOF
     59  1.1  christos 
     60  1.1  christos : ${DIFF=diff}
     61  1.1  christos ${DIFF} prog.ok prog.pot || exit 1
     62  1.1  christos 
     63  1.1  christos # The output of rstconv is slightly different:
     64  1.1  christos # - ModuleName:ConstName instead of ModuleName.ConstName
     65  1.1  christos # - no line wrapping
     66  1.1  christos # - extra newline at the end
     67  1.1  christos 
     68  1.1  christos tmpfiles="$tmpfiles prog.pot"
     69  1.1  christos : ${RSTCONV=rstconv}
     70  1.1  christos if (${RSTCONV} -o prog.pot -i prog.rst) >/dev/null 2>&1; then
     71  1.1  christos 
     72  1.1  christos tmpfiles="$tmpfiles prog.ok"
     73  1.1  christos cat <<EOF > prog.ok
     74  1.1  christos #: rstconv:help
     75  1.1  christos msgid "rstconv [-h|--help]    Displays this help\nrstconv options        Convert rst file\n\nOptions are:\n  -i file    Use specified file instead of stdin as input .rst (OPTIONAL)\n  -o file    Write output to specified file (REQUIRED)\n  -f format  Specifies the output format:\n             po    GNU gettext .po (portable) format (DEFAULT)\n"
     76  1.1  christos msgstr ""
     77  1.1  christos 
     78  1.1  christos #: rstconv:InvalidOption
     79  1.1  christos msgid "Invalid option - "
     80  1.1  christos msgstr ""
     81  1.1  christos 
     82  1.1  christos #: rstconv:OptionAlreadySpecified
     83  1.1  christos msgid "Option has already been specified - "
     84  1.1  christos msgstr ""
     85  1.1  christos 
     86  1.1  christos #: rstconv:NoOutFilename
     87  1.1  christos msgid "No output filename specified"
     88  1.1  christos msgstr ""
     89  1.1  christos 
     90  1.1  christos #: rstconv:InvalidOutputFormat
     91  1.1  christos msgid "Invalid output format -"
     92  1.1  christos msgstr ""
     93  1.1  christos 
     94  1.1  christos EOF
     95  1.1  christos 
     96  1.1  christos : ${DIFF=diff}
     97  1.1  christos ${DIFF} prog.ok prog.pot || exit 1
     98  1.1  christos 
     99  1.1  christos fi
    100  1.1  christos 
    101  1.1  christos rm -fr $tmpfiles
    102  1.1  christos 
    103  1.1  christos exit 0
    104