py-compile-usage.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #! /bin/sh
  2. # Copyright (C) 2011-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 'py-compile --help', 'py-compile --version', and that 'py-compile'
  17. # correctly complains on wrong usage.
  18. . test-init.sh
  19. cp "$am_scriptdir/py-compile" . \
  20. || fatal_ "failed to fetch auxiliary script py-compile"
  21. # --help
  22. ./py-compile --help >stdout 2>stderr \
  23. || { cat stdout; cat stderr >&2; exit 1; }
  24. cat stdout
  25. test -s stderr && { cat stderr >&2; exit 1; }
  26. grep '^Usage: py-compile .' stdout
  27. $FGREP ' [--basedir DIR]' stdout
  28. $FGREP ' [--destdir DIR]' stdout
  29. # --version
  30. ./py-compile --version >stdout 2>stderr \
  31. || { cat stdout; cat stderr >&2; exit 1; }
  32. cat stdout
  33. test -s stderr && { cat stderr >&2; exit 1; }
  34. year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
  35. month='(0[0-9]|1[012])'
  36. day='([012][0-9]|3[01])'
  37. hour='([01][0-9]|2[0123])'
  38. LC_ALL=C $EGREP "^py-compile $year-$month-$day\.$hour" stdout
  39. test $(wc -l <stdout) -eq 1
  40. # Unknown option.
  41. for opt in -b -d --foo; do
  42. ./py-compile $opt 2>stderr && { cat stderr >&2; exit 1; }
  43. cat stderr >&2
  44. grep "^py-compile: unrecognized option '$opt'" stderr
  45. grep "^Try 'py-compile --help' for more information" stderr
  46. done
  47. # Missing option argument.
  48. for opt in --basedir --destdir; do
  49. ./py-compile $opt 2>stderr && { cat stderr >&2; exit 1; }
  50. cat stderr >&2
  51. grep "^py-compile: option '$opt' requires an argument" stderr
  52. grep "^Try 'py-compile --help' for more information" stderr
  53. done
  54. # Missing files.
  55. for args in '' '--basedir dir' '--destdir dir'; do
  56. ./py-compile $args 2>stderr && { cat stderr >&2; exit 1; }
  57. cat stderr >&2
  58. grep '^py-compile: no files given' stderr
  59. grep "^Try 'py-compile --help' for more information" stderr
  60. done
  61. :