automake-cmdline.tap 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #! /bin/sh
  2. # Copyright (C) 2004-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Test Automake's command-line options.
  17. . test-init.sh
  18. plan_ 17
  19. # Usage: bad_cmdline DESCRIPTION REGEX-FOR-STDERR [ARGS-FOR-AUTOMAKE...]
  20. do_check ()
  21. {
  22. test $# -ge 3 || fatal_ "do_check: invalid usage"
  23. desc=$1; shift
  24. regex=$1; shift
  25. AUTOMAKE_fails -d "$desc (run)" -- "$@"
  26. command_ok_ "$desc (stderr)" grep "$regex" stderr
  27. }
  28. do_check 'invalid long option' 'unrecognized option.*--voo' --voo
  29. # Older perl has a buggy Getopt::Long which makes this fail.
  30. if $PERL -e 'require 5.8.2;'; then
  31. do_check "list of options terminated by '--'" \
  32. 'input file.*--voo' -- --voo
  33. else
  34. skip_row_ 2 -r "older perl with buggy Getopt::Long"
  35. fi
  36. do_check "empty argument" \
  37. 'empty argument' ''
  38. do_check "missing argument for long option" \
  39. 'option.*-W.*requires an argument' -W
  40. do_check "missing argument for short option" \
  41. 'option.*--warnings.*requires an argument' --warnings
  42. do_check "'--help' as option argument" \
  43. 'unknown warning.*--help' --warnings --help
  44. do_check "'--help' as option argument" \
  45. 'unknown warning.*--help' --warnings --help
  46. do_check "ambiguous incomplete option" \
  47. 'unrecognized option.*--ver' --ver
  48. command_ok_ "unambiguous incomplete long option" $AUTOMAKE --vers
  49. :