From 8355b2b59221c58b33d686a0a2b4f22a19a3c330 Mon Sep 17 00:00:00 2001 From: Stefano Lattarini Date: Fri, 4 Nov 2011 20:15:12 +0100 Subject: [PATCH] test defs: new functions to analyze configure help screen * tests/defs (extract_configure_help, grep_configure_help): New functions. * tests/maintmode-configure-msg.test: Use them, reducing code duplication and test brittleness. * tests/help-depend.test: Likewise. * tests/help-depend2.test: Likewise. * tests/help-dmalloc.test: Likewise. * tests/help-lispdir.test: Likewise. * tests/help-multilib.test: Likewise. * tests/help-python.test: Likewise. * tests/help-regex.test: Likewise. * tests/help-silent.test: Likewise. * tests/help-upc.test: Likewise. * tests/help-init.test: Make grepping of configure help screen slightly stricter. * tests/self-check-configure-help.test: New self test. * tests/Makefile.am (TESTS): Add it. From a report by Jim Meyering. --- ChangeLog | 22 +++ tests/Makefile.am | 1 + tests/Makefile.in | 1 + tests/defs | 48 ++++++ tests/help-depend.test | 10 +- tests/help-depend2.test | 10 +- tests/help-dmalloc.test | 7 +- tests/help-init.test | 6 +- tests/help-lispdir.test | 9 +- tests/help-multilib.test | 6 +- tests/help-python.test | 5 +- tests/help-regex.test | 7 +- tests/help-silent.test | 12 +- tests/help-upc.test | 7 +- tests/maintmode-configure-msg.test | 10 +- tests/self-check-configure-help.test | 274 +++++++++++++++++++++++++++++++++++ 16 files changed, 375 insertions(+), 60 deletions(-) create mode 100755 tests/self-check-configure-help.test diff --git a/ChangeLog b/ChangeLog index 7363e1a..f22fa84 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,25 @@ +2011-11-04 Stefano Lattarini + + test defs: new functions to analyze configure help screen + * tests/defs (extract_configure_help, grep_configure_help): New + functions. + * tests/maintmode-configure-msg.test: Use them, reducing code + duplication and test brittleness. + * tests/help-depend.test: Likewise. + * tests/help-depend2.test: Likewise. + * tests/help-dmalloc.test: Likewise. + * tests/help-lispdir.test: Likewise. + * tests/help-multilib.test: Likewise. + * tests/help-python.test: Likewise. + * tests/help-regex.test: Likewise. + * tests/help-silent.test: Likewise. + * tests/help-upc.test: Likewise. + * tests/help-init.test: Make grepping of configure help screen + slightly stricter. + * tests/self-check-configure-help.test: New self test. + * tests/Makefile.am (TESTS): Add it. + From a report by Jim Meyering. + 2011-11-03 Stefano Lattarini tests: various minor tweakings, mostly related to AM_PROG_AR diff --git a/tests/Makefile.am b/tests/Makefile.am index b5ad95a..00af436 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -900,6 +900,7 @@ reqd2.test \ repeated-options.test \ rulepat.test \ self-check-cleanup.test \ +self-check-configure-help.test \ self-check-dir.test \ self-check-env-sanitize.test \ self-check-exit.test \ diff --git a/tests/Makefile.in b/tests/Makefile.in index babba97..1179ed2 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -1176,6 +1176,7 @@ reqd2.test \ repeated-options.test \ rulepat.test \ self-check-cleanup.test \ +self-check-configure-help.test \ self-check-dir.test \ self-check-env-sanitize.test \ self-check-exit.test \ diff --git a/tests/defs b/tests/defs index 1c9dd90..93a2106 100644 --- a/tests/defs +++ b/tests/defs @@ -186,6 +186,54 @@ AUTOMAKE_fails () AUTOMAKE_run 1 ${1+"$@"} } +# extract_configure_help { --OPTION | VARIABLE-NAME } [FILES] +# ----------------------------------------------------------- +# Use this to extract from the output of `./configure --help' (or similar) +# the description or help message associated to the given --OPTION or +# VARIABLE-NAME. +extract_configure_help () +{ + am__opt_re='' am__var_re='' + case $1 in + --*'=') am__opt_re="^ $1";; + --*'[=]') am__opt_re='^ '`printf '%s\n' "$1" | sed 's/...$//'`'\[=';; + --*) am__opt_re="^ $1( .*|$)";; + *) am__var_re="^ $1( .*|$)";; + esac + shift + if test x"$am__opt_re" != x; then + LC_ALL=C awk ' + /'"$am__opt_re"'/ { print; do_print = 1; next; } + /^$/ { do_print = 0; next } + /^ --/ { do_print = 0; next } + (do_print == 1) { print } + ' ${1+"$@"} + else + LC_ALL=C awk ' + /'"$am__var_re"'/ { print; do_print = 1; next; } + /^$/ { do_print = 0; next } + /^ [A-Z][A-Z0-9_]* / { do_print = 0; next } + /^ [A-Z][A-Z0-9_]*$/ { do_print = 0; next } + (do_print == 1) { print } + ' ${1+"$@"} + fi +} + +# grep_configure_help { --OPTION | VARIABLE-NAME } REGEXP +# ------------------------------------------------------- +# Grep the section of `./configure --help' output associated with either +# --OPTION or VARIABLE-NAME for the given *extended* regular expression. +grep_configure_help () +{ + ./configure --help > am--all-help \ + || { cat am--all-help; Exit 1; } + cat am--all-help + extract_configure_help "$1" am--all-help > am--our-help \ + || { cat am--our-help; Exit 1; } + cat am--our-help + $EGREP "$2" am--our-help || Exit 1 +} + # using_gmake # ----------- # Return success if $MAKE is GNU make, return failure otherwise. diff --git a/tests/help-depend.test b/tests/help-depend.test index e25f264..651e048 100755 --- a/tests/help-depend.test +++ b/tests/help-depend.test @@ -28,12 +28,10 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout +grep_configure_help --enable-dependency-tracking \ + ' not reject slow dependency extract' -$EGREP '^ *--enable-dependency-tracking( |$)' stdout -$EGREP '^ *--disable-dependency-tracking( |$)' stdout -$FGREP ' speeds up one-time build' stdout -$FGREP ' slow dependency extract' stdout +grep_configure_help --disable-dependency-tracking \ + ' speeds up one-time build' : diff --git a/tests/help-depend2.test b/tests/help-depend2.test index 0eb5447..d44ff7a 100755 --- a/tests/help-depend2.test +++ b/tests/help-depend2.test @@ -29,12 +29,10 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout +grep_configure_help --enable-dependency-tracking \ + ' not reject slow dependency extract' -$EGREP '^ *--enable-dependency-tracking( |$)' stdout -$EGREP '^ *--disable-dependency-tracking( |$)' stdout -$FGREP ' speeds up one-time build' stdout -$FGREP ' slow dependency extract' stdout +grep_configure_help --disable-dependency-tracking \ + ' speeds up one-time build' : diff --git a/tests/help-dmalloc.test b/tests/help-dmalloc.test index 708805b..dc8c4c1 100755 --- a/tests/help-dmalloc.test +++ b/tests/help-dmalloc.test @@ -27,11 +27,6 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout - -$EGREP '^ *--with-dmalloc( |$) ' stdout -$FGREP ' use dmalloc' stdout -$FGREP 'www.dmalloc.com' stdout +grep_configure_help --with-dmalloc ' use dmalloc.*http://www\.dmalloc\.com' : diff --git a/tests/help-init.test b/tests/help-init.test index 7698623..8b5ec71 100755 --- a/tests/help-init.test +++ b/tests/help-init.test @@ -30,8 +30,8 @@ $AUTOCONF ./configure --help >stdout || { cat stdout; Exit 1; } cat stdout -grep '^ *--program-prefix[= ]' stdout -grep '^ *--program-suffix[= ]' stdout -grep '^ *--program-transform-name[= ]' stdout +grep '^ --program-prefix[= ]' stdout +grep '^ --program-suffix[= ]' stdout +grep '^ --program-transform-name[= ]' stdout : diff --git a/tests/help-lispdir.test b/tests/help-lispdir.test index a308021..9a72189 100755 --- a/tests/help-lispdir.test +++ b/tests/help-lispdir.test @@ -30,11 +30,8 @@ $AUTOCONF ./configure --help >stdout || { cat stdout; Exit 1; } cat stdout -$EGREP '^ *--with-lispdir( |$)' stdout -grep ' override.*lisp directory' stdout -$EGREP '^ *EMACS( |$)' stdout -grep ' .*[eE]macs editor' stdout -$EGREP '^ *EMACSLOADPATH( |$)' stdout -grep ' .*[eE]macs library search path' stdout +grep_configure_help --with-lispdir ' override.*lisp directory' +grep_configure_help EMACS ' [eE]macs editor' +grep_configure_help EMACSLOADPATH ' [eE]macs library search path' : diff --git a/tests/help-multilib.test b/tests/help-multilib.test index e0bf6c7..d4df64d 100755 --- a/tests/help-multilib.test +++ b/tests/help-multilib.test @@ -27,10 +27,6 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout - -$EGREP '^ *--enable-multilib( |$)' stdout -$FGREP ' many library versions (default)' stdout +grep_configure_help --enable-multilib ' many library versions \(default\)' : diff --git a/tests/help-python.test b/tests/help-python.test index e6a6fd3..9e4e48a 100755 --- a/tests/help-python.test +++ b/tests/help-python.test @@ -27,9 +27,6 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout - -grep '^ *PYTHON *the Python interpreter$' stdout +grep_configure_help PYTHON 'the Python interpreter' : diff --git a/tests/help-regex.test b/tests/help-regex.test index aecfed9..2ae7704 100755 --- a/tests/help-regex.test +++ b/tests/help-regex.test @@ -26,11 +26,6 @@ END $ACLOCAL $AUTOCONF - -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout - -$FGREP ' --without-regex ' stdout -$FGREP ' use GNU rx ' stdout +grep_configure_help --without-regex ' use GNU rx($| )' : diff --git a/tests/help-silent.test b/tests/help-silent.test index e41d166..855be52 100755 --- a/tests/help-silent.test +++ b/tests/help-silent.test @@ -28,16 +28,16 @@ $ACLOCAL mv -f configure.in configure.tmpl +q="[\`'\"]" + for args in '' '([])' '([yes])' '([no])'; do sed "s/AM_SILENT_RULES.*/&$args/" configure.tmpl >configure.in cat configure.in $AUTOCONF --force - ./configure --help >stdout || { cat stdout; Exit 1; } - cat stdout - $EGREP '^ *--enable-silent-rules( |$)' stdout - grep ' less verbose build.*undo.*make V=1' stdout - $EGREP '^ *--disable-silent-rules ( |$)' stdout - grep ' verbose build.*undo.*make V=0' stdout + grep_configure_help --enable-silent-rules \ + " less verbose build.*\\(undo.*${q}make V=1${q}" + grep_configure_help --disable-silent-rules \ + " verbose build.*\\(undo.*${q}make V=0${q}" done : diff --git a/tests/help-upc.test b/tests/help-upc.test index a30c84c..0438b4d 100755 --- a/tests/help-upc.test +++ b/tests/help-upc.test @@ -27,10 +27,7 @@ END $ACLOCAL $AUTOCONF -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout - -grep '^ *UPCFLAGS .*Unified Parallel C compiler flags' stdout -grep '^ *UPC .*Unified Parallel C compiler command' stdout +grep_configure_help UPC '[Uu]nified Parallel C compiler command' +grep_configure_help UPCFLAGS '[Uu]nified Parallel C compiler flags' : diff --git a/tests/maintmode-configure-msg.test b/tests/maintmode-configure-msg.test index 5771392..f32c4fa 100755 --- a/tests/maintmode-configure-msg.test +++ b/tests/maintmode-configure-msg.test @@ -49,9 +49,7 @@ $ACLOCAL $AUTOCONF --force -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout -grep '^ *--enable-maintainer-mode.* enable make rules' stdout +grep_configure_help --enable-maintainer-mode 'enable make rules' check_configure_message_with "no" check_configure_message_with "yes" --enable-maintainer-mode @@ -59,9 +57,7 @@ check_configure_message_with "yes" --enable-maintainer-mode set_maintmode "disable" $AUTOCONF --force -./configure --help >stdout || { cat stdout; Exit 1; } -cat stdout -grep '^ *--enable-maintainer-mode.* enable make rules' stdout +grep_configure_help --enable-maintainer-mode 'enable make rules' check_configure_message_with "no" check_configure_message_with "yes" --enable-maintainer-mode @@ -71,7 +67,7 @@ set_maintmode "enable" $AUTOCONF --force ./configure --help >stdout || { cat stdout; Exit 1; } cat stdout -grep '^ *--disable-maintainer-mode.* disable make rules' stdout +grep_configure_help --disable-maintainer-mode 'disable make rules' check_configure_message_with "yes" check_configure_message_with "no" --disable-maintainer-mode diff --git a/tests/self-check-configure-help.test b/tests/self-check-configure-help.test new file mode 100755 index 0000000..16f4b50 --- /dev/null +++ b/tests/self-check-configure-help.test @@ -0,0 +1,274 @@ +#! /bin/sh +# Copyright (C) 2011 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +# Sanity check on the function used by the automake testsuite to +# analyze output of "configure --help". + +. ./defs || Exit 1 + +# FIXME: this test is a good candidate for a conversion to TAP. + +# Prefer real-world data. This is from the help screen of the +# configure script from GNU coreutils, with small adaptations. +cat > help <<'END' +`configure' configures GNU coreutils 8.14a to adapt to many kinds of systems. + +Usage: ./configure [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print `checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for `--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or `..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [/usr/local] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, `make install' will install all the files in +`/usr/local/bin', `/usr/local/lib' etc. You can specify +an installation prefix other than `/usr/local' using `--prefix', +for instance `--prefix=$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/coreutils] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] + +Program names: + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM run sed PROGRAM on installed program names + +System types: + --build=BUILD configure for building on BUILD [guessed] + --host=HOST cross-compile to build programs to run on HOST [BUILD] + +Optional Features: + --disable-option-checking ignore unrecognized --enable/--with options + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --enable-silent-rules less verbose build output (undo: `make V=1') + --disable-silent-rules verbose build output (undo: `make V=0') + --disable-dependency-tracking speeds up one-time build + --enable-dependency-tracking do not reject slow dependency extractors + --disable-largefile omit support for large files + --enable-threads={posix|solaris|pth|win32} + specify multithreading API + --disable-threads build without multithread safety + --disable-acl do not support ACLs + --disable-assert turn off assertions + --disable-rpath do not hardcode runtime library paths + --disable-xattr do not support extended attributes + --disable-libcap disable libcap support + --enable-gcc-warnings turn on lots of GCC warnings (for developers) + --enable-install-program=PROG_LIST + install the programs in PROG_LIST (comma-separated, + default: none) + --enable-no-install-program=PROG_LIST + do NOT install the programs in PROG_LIST + (comma-separated, default: arch,hostname,su) + --disable-nls do not use Native Language Support + +Optional Packages: + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --with-gnu-ld assume the C compiler uses GNU ld default=no + --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib + --without-libiconv-prefix don't search for libiconv in includedir and libdir + --with-libpth-prefix[=DIR] search for libpth in DIR/include and DIR/lib + --without-libpth-prefix don't search for libpth in includedir and libdir + --without-included-regex + don't compile regex; this is the default on systems + with recent-enough versions of the GNU C Library + (use with caution on other systems). + --without-selinux do not use SELinux, even on systems with SELinux + --with-packager String identifying the packager of this software + --with-packager-version Packager-specific version information + --with-packager-bug-reports + Packager info for bug reports (URL/e-mail/...) + --with-tty-group[=NAME] + group used by system for TTYs, "tty" when not + specified (default: do not rely on any group used + for TTYs) + --without-gmp do not use the GNU MP library for arbitrary + precision calculation (default: use it if available) + --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib + --without-libintl-prefix don't search for libintl in includedir and libdir + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + YACC The `Yet Another C Compiler' implementation to use. Defaults to + `bison -y'. Values other than `bison -y' will most likely break + on most systems. + YFLAGS YFLAGS contains the list arguments that will be passed by + default to Bison. This script will default YFLAGS to the empty + string to avoid a default value of `-d' given by some make + applications. + DEFAULT_POSIX2_VERSION + POSIX version to default to; see 'config.hin'. + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to . +General help using GNU software: . +END + +compare_extracted_help () +{ + cat > exp || Exit 99 + extract_configure_help "$1" help > got || Exit 1 + cat exp + cat got + diff exp got || Exit 1 +} + +compare_extracted_help --disable-libcap <<'END' + --disable-libcap disable libcap support +END + +compare_extracted_help --disable-nls <<'END' + --disable-nls do not use Native Language Support +END + +compare_extracted_help --disable-option-checking <<'END' + --disable-option-checking ignore unrecognized --enable/--with options +END + +compare_extracted_help --build= <<'END' + --build=BUILD configure for building on BUILD [guessed] +END + +compare_extracted_help --host= <<'END' + --host=HOST cross-compile to build programs to run on HOST [BUILD] +END + +compare_extracted_help '--with-libintl-prefix[=]' <<'END' + --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib +END + +compare_extracted_help --without-included-regex <<'END' + --without-included-regex + don't compile regex; this is the default on systems + with recent-enough versions of the GNU C Library + (use with caution on other systems). +END + +compare_extracted_help --enable-threads= <<'END' + --enable-threads={posix|solaris|pth|win32} + specify multithreading API +END + +compare_extracted_help '--with-tty-group[=]' <<'END' + --with-tty-group[=NAME] + group used by system for TTYs, "tty" when not + specified (default: do not rely on any group used + for TTYs) +END + +compare_extracted_help '--prefix=' <<'END' + --prefix=PREFIX install architecture-independent files in PREFIX + [/usr/local] +END + +compare_extracted_help '--exec-prefix=' <<'END' + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] +END + +compare_extracted_help CC <<'END' + CC C compiler command +END + +compare_extracted_help CPP <<'END' + CPP C preprocessor +END + +compare_extracted_help CPPFLAGS <<'END' + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory +END + +compare_extracted_help YACC <<'END' + YACC The `Yet Another C Compiler' implementation to use. Defaults to + `bison -y'. Values other than `bison -y' will most likely break + on most systems. +END + +compare_extracted_help DEFAULT_POSIX2_VERSION <<'END' + DEFAULT_POSIX2_VERSION + POSIX version to default to; see 'config.hin'. +END + +for o in \ + '--nonesuch' \ + '--nonesuch=' \ + '--nonesuch[=]' \ + '--disable-nls=' \ + '--disable-nls[=]' \ + '--without-included-regex=' \ + '--without-included-regex[=]' \ + '--prefix' \ + '--prefix[=]' \ + '--build' \ + '--build[=]' \ + '--with-tty-group' \ + '--with-tty-group=' \ + 'NO_SUCH_VAR' \ + 'NOSUCHVAR' \ +; do + compare_extracted_help "$o"