"Fossies" - the Fresh Open Source Software Archive

Member "gnuastro-0.8/bootstrapped/tests/test-argp-2.sh" (28 Dec 2018, 3404 Bytes) of package /linux/privat/gnuastro-0.8.tar.lz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "test-argp-2.sh": 0.5_vs_0.6.

    1 #! /bin/sh
    2 # Test suite for argp.
    3 # Copyright (C) 2006-2018 Free Software Foundation, Inc.
    4 # This file is part of the GNUlib Library.
    5 #
    6 # This program is free software: you can redistribute it and/or modify
    7 # it under the terms of the GNU General Public License as published by
    8 # the Free Software Foundation; either version 3 of the License, or
    9 # (at your option) any later version.
   10 #
   11 # This program is distributed in the hope that it will be useful,
   12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
   13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   14 # GNU General Public License for more details.
   15 #
   16 # You should have received a copy of the GNU General Public License
   17 # along with this program.  If not, see <https://www.gnu.org/licenses/>.  */
   18 
   19 TMP=argp.$$
   20 
   21 unset ARGP_HELP_FMT
   22 ERR=0
   23 
   24 func_compare() {
   25 # If argp was compiled without base_name, it will display full program name.
   26 # If run on mingw, it will display the program name with a .exe suffix.
   27   sed '1{
   28          s,: [^ ]*/test-argp,: test-argp,
   29          s,: test-argp\.exe,: test-argp,
   30         }' | LC_ALL=C tr -d '\r' | diff -c $TMP -
   31 }
   32 
   33 ####
   34 # Test --usage output
   35 cat > $TMP <<EOT
   36 Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
   37             [--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga]
   38             [--sonet] [--option] [--optional[=ARG]] [--many] [--one] [--two]
   39             [--limerick] [--poem] [--help] [--usage] [--version] ARGS...
   40 EOT
   41 
   42 ./test-argp$EXEEXT --usage | func_compare || ERR=1
   43 
   44 ####
   45 # Test working usage-indent format
   46 
   47 cat > $TMP <<EOT
   48 Usage: test-argp [-tvCSOlp?V] [-f FILE] [-r FILE] [-o[ARG]] [--test]
   49 [--file=FILE] [--input=FILE] [--read=FILE] [--verbose] [--cantiga] [--sonet]
   50 [--option] [--optional[=ARG]] [--many] [--one] [--two] [--limerick] [--poem]
   51 [--help] [--usage] [--version] ARGS...
   52 EOT
   53 
   54 ARGP_HELP_FMT='usage-indent=0' ./test-argp$EXEEXT --usage | func_compare || ERR=1
   55 
   56 ####
   57 # Test --help output
   58 cat >$TMP <<EOT
   59 Usage: test-argp [OPTION...] ARGS...
   60 documentation string
   61 
   62  Main options
   63   -t, --test
   64 
   65  Option Group 1
   66   -f, -r, --file=FILE, --input=FILE, --read=FILE
   67                              Option with a mandatory argument
   68   -v, --verbose              Simple option without arguments
   69 
   70  Option Group 1.1
   71   -C, --cantiga              create a cantiga
   72   -S, --sonet                create a sonet
   73 
   74  Option Group 2
   75   -O, --option               An option
   76 
   77   -o, --optional[=ARG]       Option with an optional argument. ARG is one of
   78                              the following:
   79 
   80   many                       many units
   81   one                        one unit
   82   two                        two units
   83 
   84  Option Group 2.1
   85   -l, --limerick             create a limerick
   86   -p, --poem                 create a poem
   87 
   88   -?, --help                 give this help list
   89       --usage                give a short usage message
   90   -V, --version              print program version
   91 
   92 Mandatory or optional arguments to long options are also mandatory or optional
   93 for any corresponding short options.
   94 
   95 Report bugs to <>.
   96 EOT
   97 
   98 # Compare --help output, but filter out any bug-reporting email address.
   99 ./test-argp$EXEEXT --help \
  100     | sed 's/^\(Report bugs to \)<[^>]*>.$/\1<>./' | func_compare || ERR=1
  101 
  102 ####
  103 # Test ambiguous option handling
  104 
  105 ./test-argp$EXEEXT --optio 2>/dev/null && ERR=1
  106 
  107 ####
  108 # Run built-in tests
  109 ./test-argp$EXEEXT || ERR=1
  110 
  111 rm $TMP
  112 
  113 exit $ERR