2 # Copyright (C) 2011 Free Software Foundation, Inc.
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)
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.
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/>.
17 # Test `py-compile --help', `py-compile --version', and that `py-compile'
18 # correctly complains on wrong usage.
24 cp "$testsrcdir/../lib/py-compile" .
28 ./py-compile --help >stdout 2>stderr \
29 || { cat stdout; cat stderr >&2; Exit 1; }
31 test -s stderr && { cat stderr >&2; Exit 1; }
32 grep '^Usage: py-compile .' stdout
33 $FGREP ' [--basedir DIR]' stdout
34 $FGREP ' [--destdir DIR]' stdout
38 ./py-compile --version >stdout 2>stderr \
39 || { cat stdout; cat stderr >&2; Exit 1; }
41 test -s stderr && { cat stderr >&2; Exit 1; }
42 year='20[0-9][0-9]' # Hopefully automake will be obsolete in 80 years ;-)
43 month='(0[0-9]|1[012])'
44 day='([012][0-9]|3[01])'
45 hour='([01][0-9]|2[0123])'
46 LC_ALL=C $EGREP "^py-compile $year-$month-$day\.$hour" stdout
47 test `wc -l <stdout` -eq 1
50 for opt in -b -d --foo; do
51 ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
53 grep "^py-compile: unrecognized option ['\`]$opt'" stderr
54 grep "^Try [\`']py-compile --help' for more information" stderr
57 # Missing option argument.
59 for opt in --basedir --destdir; do
60 ./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
62 grep "^py-compile: option ['\`]$opt' requires an argument" stderr
63 grep "^Try [\`']py-compile --help' for more information" stderr
68 for args in '' '--basedir dir' '--destdir dir'; do
69 ./py-compile $args 2>stderr && { cat stderr >&2; Exit 1; }
71 grep '^py-compile: no files given' stderr
72 grep "^Try [\`']py-compile --help' for more information" stderr