2011-06-08 Stefano Lattarini <stefano.lattarini@gmail.com>
+ py-compile: normalize error and help messages
+ * lib/py-compile: Now error messages do not begin with a capital
+ letter, nor end with a period, as per GNU standards. Prepend the
+ error messages with the name of the script, not with its path.
+ When an invalid usage is recognized, always display the customary
+ message "Try `py-compile --help' ..." on a line of its own.
+ ($me): New variable, containing the name of the
+ program, i.e., `py-compile'. Use it throughout.
+ (usage_error): New function, used to display error messages about
+ invalid usage.
+ * tests/py-compile-usage.test: Extend and tighten accordingly.
+
+2011-06-08 Stefano Lattarini <stefano.lattarini@gmail.com>
+
python tests: add "unit tests" on py-compile
* tests/py-compile-basic.test: New test.
* tests/py-compile-basic2.test: New test.
PYTHON=python
fi
+me=py-compile
+
+usage_error ()
+{
+ echo "$me: $*" >&2
+ echo "Try \`$me --help' for more information." >&2
+ exit 1
+}
+
basedir=
destdir=
files=
case "$1" in
--basedir)
if test $# -lt 2; then
- echo "$0: Missing argument to --basedir." 1>&2
- exit 1
+ usage_error "option '--basedir' requires an argument"
else
basedir=$2
fi
;;
--destdir)
if test $# -lt 2; then
- echo "$0: Missing argument to --destdir." 1>&2
- exit 1
+ usage_error "option '--destdir' requires an argument"
else
destdir=$2
fi
exit $?
;;
-v|--v*)
- echo "py-compile $scriptversion"
+ echo "$me $scriptversion"
exit $?
;;
*)
done
if test -z "$files"; then
- echo "$0: No files given. Try \`$0 --help' for more information." 1>&2
- exit 1
+ usage_error "no files given"
fi
# if basedir was given, then it should be prepended to filenames before
for opt in --basedir --destdir; do
./py-compile $opt 2>stderr && { cat stderr >&2; Exit 1; }
cat stderr >&2
- grep "py-compile:.* [Mm]issing argument.*$opt" stderr
+ grep "^py-compile: option ['\`]$opt' requires an argument" stderr
+ grep "^Try [\`']py-compile --help' for more information" stderr
done
# Missing files.
for args in '' '--basedir dir' '--destdir dir'; do
./py-compile $args 2>stderr && { cat stderr >&2; Exit 1; }
cat stderr >&2
- grep 'py-compile:.* [nN]o files given' stderr
- grep "Try [\`'].*py-compile --help' for more information" stderr
+ grep '^py-compile: no files given' stderr
+ grep "^Try [\`']py-compile --help' for more information" stderr
done
: