gnulib-tool --test --dir=directory module1 ... moduleN
gnulib-tool --megatest --dir=directory [module1 ... moduleN]
gnulib-tool --extract-description module
+ gnulib-tool --extract-comment module
gnulib-tool --extract-status module
gnulib-tool --extract-notice module
gnulib-tool --extract-applicability module
--megatest test the given modules one by one and all together
(recommended to use CC=\"gcc -Wall\" here)
--extract-description extract the description
- --extract-status extract the status (obsolete or not)
+ --extract-comment extract the comment
+ --extract-status extract the status (obsolete etc.)
--extract-notice extract the notice or banner
+ --extract-applicability extract the applicability
--extract-filelist extract the list of files
--extract-dependencies extract the dependencies
--extract-autoconf-snippet extract the snippet for configure.ac
'gl_INIT'. Default is 'gl'.
--po-domain=NAME Specify the prefix of the i18n domain. Usually use
the package name. A suffix '-gnulib' is appended.
+ --with-c++-tests Include even unit tests for C++ interoperability.
+ --with-longrunning-tests
+ Include even unit tests that are long-runners.
+ --with-privileged-tests
+ Include even unit tests that require root
+ privileges.
+ --with-unportable-tests
+ Include even unit tests that fail on some platforms.
+ --with-all-tests Include all kinds of problematic unit tests.
--vc-files Update version control related files.
--no-vc-files Don't update version control related files
(.gitignore and/or .cvsignore).
# - auxdir from --aux-dir
# - inctests true if --with-tests was given, blank otherwise
# - incobsolete true if --with-obsolete was given, blank otherwise
+# - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
+# - inc_longrunning_tests true if --with-longrunning-tests was given, blank
+# otherwise
+# - inc_privileged_tests true if --with-privileged-tests was given, blank
+# otherwise
+# - inc_unportable_tests true if --with-unportable-tests was given, blank
+# otherwise
+# - inc_all_tests true if --with-all-tests was given, blank otherwise
# - avoidlist list of modules to avoid, from --avoid
# - lgpl yes or a number if --lgpl was given, blank otherwise
# - makefile_name from --makefile-name
auxdir=
inctests=
incobsolete=
+ inc_cxx_tests=
+ inc_longrunning_tests=
+ inc_privileged_tests=
+ inc_unportable_tests=
+ inc_all_tests=
avoidlist=
lgpl=
makefile_name=
--aux-dir=* )
auxdir=`echo "X$1" | sed -e 's/^X--aux-dir=//'`
shift ;;
- --with-tests )
+ --with-tests | --with-test | --with-tes | --with-te | --with-t)
inctests=true
shift ;;
- --with-obsolete )
+ --with-obsolete | --with-obsolet | --with-obsole | --with-obsol | --with-obso | --with-obs | --with-ob | --with-o)
incobsolete=true
shift ;;
+ --with-c++-tests | --with-c++-test | --with-c++-tes | --with-c++-te | --with-c++-t | --with-c++- | --with-c++ | --with-c+ | --with-c)
+ inc_cxx_tests=true
+ shift ;;
+ --with-longrunning-tests | --with-longrunning-test | --with-longrunning-tes | --with-longrunning-te | --with-longrunning-t | --with-longrunning- | --with-longrunning | --with-longrunnin | --with-longrunni | --with-longrunn | --with-longrun | --with-longru | --with-longr | --with-long | --with-lon | --with-lo | --with-l)
+ inc_longrunning_tests=true
+ shift ;;
+ --with-privileged-tests | --with-privileged-test | --with-privileged-tes | --with-privileged-te | --with-privileged-t | --with-privileged- | --with-privileged | --with-privilege | --with-privileg | --with-privile | --with-privil | --with-privi | --with-priv | --with-pri | --with-pr | --with-p)
+ inc_privileged_tests=true
+ shift ;;
+ --with-unportable-tests | --with-unportable-test | --with-unportable-tes | --with-unportable-te | --with-unportable-t | --with-unportable- | --with-unportable | --with-unportabl | --with-unportab | --with-unporta | --with-unport | --with-unpor | --with-unpo | --with-unp | --with-un | --with-u)
+ inc_unportable_tests=true
+ shift ;;
+ --with-all-tests | --with-all-test | --with-all-tes | --with-all-te | --with-all-t | --with-all- | --with-all | --with-al | --with-a)
+ inc_all_tests=true
+ shift ;;
--avoid )
shift
if test $# = 0; then
|| test -n "$sourcebase" || test -n "$m4base" || test -n "$pobase" \
|| test -n "$docbase" || test -n "$testsbase" || test -n "$auxdir" \
|| test -n "$inctests" || test -n "$incobsolete" \
+ || test -n "$inc_cxx_tests" || test -n "$inc_longrunning_tests" \
+ || test -n "$inc_privileged_tests" || test -n "$inc_unportable_tests" \
+ || test -n "$inc_all_tests" \
|| test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \
|| test -n "$macro_prefix" || test -n "$po_domain" \
|| test -n "$vc_files"; then
| LC_ALL=C sort -u
}
+# func_exists_module module
+# tests whether a module, given by name, exists
+# Input:
+# - local_gnulib_dir from --local-dir
+func_exists_module ()
+{
+ { test -f "$gnulib_dir/modules/$1" \
+ || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
+ && test -f "$local_gnulib_dir/modules/$1"; }; } \
+ && test "CVS" != "$1" \
+ && test "ChangeLog" != "$1" \
+ && test "COPYING" != "$1" \
+ && test "README" != "$1" \
+ && test "TEMPLATE" != "$1" \
+ && test "TEMPLATE-EXTENDED" != "$1" \
+ && test "TEMPLATE-TESTS" != "$1"
+}
+
# func_verify_module
# verifies a module name
# Input:
# - module module name argument
func_verify_module ()
{
- if { test -f "$gnulib_dir/modules/$module" \
- || { test -n "$local_gnulib_dir" && test -d "$local_gnulib_dir/modules" \
- && test -f "$local_gnulib_dir/modules/$module"; }; } \
- && test "CVS" != "$module" \
- && test "ChangeLog" != "$module" \
- && test "COPYING" != "$module" \
- && test "README" != "$module" \
- && test "TEMPLATE" != "$module" \
- && test "TEMPLATE-EXTENDED" != "$module" \
- && test "TEMPLATE-TESTS" != "$module"; then
+ if func_exists_module "$module"; then
# OK, $module is a correct module name.
# Verify that building the module description with 'patch' succeeds.
func_lookup_file "modules/$module"
:a
n
s/^Description:[ ]*$//
+ s/^Comment:[ ]*$//
s/^Status:[ ]*$//
s/^Notice:[ ]*$//
s/^Applicability:[ ]*$//
# NOTE: Keep this in sync with sed_extract_prog above!
sed_extract_field_header='
s/^Description:[ ]*$/description/
+ s/^Comment:[ ]*$/comment/
s/^Status:[ ]*$/status/
s/^Notice:[ ]*$/notice/
s/^Applicability:[ ]*$/applicability/
fi
}
+# func_get_comment module
+# Input:
+# - local_gnulib_dir from --local-dir
+# - modcache true or false, from --cache-modules/--no-cache-modules
+func_get_comment ()
+{
+ if ! $modcache; then
+ func_lookup_file "modules/$1"
+ sed -n -e "/^Comment$sed_extract_prog" < "$lookedup_file"
+ else
+ func_cache_lookup_module "$1"
+ # Output the field's value, including the final newline (if any).
+ if $have_associative; then
+ if test -n "${modcache_comment[$1]+set}"; then
+ echo "${modcache_comment[$1]}"
+ fi
+ else
+ eval "field_set=\"\$${cachevar}_comment_set\""
+ if test -n "$field_set"; then
+ eval "field_value=\"\$${cachevar}_comment\""
+ echo "${field_value}"
+ fi
+ fi
+ fi
+}
+
# func_get_status module
# Input:
# - local_gnulib_dir from --local-dir
# - modcache true or false, from --cache-modules/--no-cache-modules
func_get_dependencies ()
{
- # ${module}-tests always implicitly depends on ${module}.
+ # ${module}-tests implicitly depends on ${module}, if that module exists.
case "$1" in
*-tests)
fgd1="$1"
func_remove_suffix fgd1 '-tests'
- echo "$fgd1"
+ if func_exists_module "$fgd1"; then
+ echo "$fgd1"
+ fi
;;
esac
# Then the explicit dependencies listed in the module description.
# func_acceptable module
# tests whether a module is acceptable.
# Input:
+# - inc_cxx_tests true if C++ interoperability tests should be included,
+# blank otherwise
+# - inc_longrunning_tests true if long-runnings tests should be included,
+# blank otherwise
+# - inc_privileged_tests true if tests that require root privileges should be
+# included, blank otherwise
+# - inc_unportable_tests true if tests that fail on some platforms should be
+# included, blank otherwise
+# - inc_all_tests true if all kinds of problematic unit tests should be
+# included, blank otherwise
# - avoidlist list of modules to avoid
func_acceptable ()
{
return 1
fi
done
+ case "$1" in
+ *-tests)
+ inc=true
+ for word in `func_get_status "$1"`; do
+ case "$word" in
+ c++-test)
+ test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \
+ || inc=false
+ ;;
+ longrunning-test)
+ test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \
+ || inc=false
+ ;;
+ privileged-test)
+ test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \
+ || inc=false
+ ;;
+ unportable-test)
+ test -n "$inc_all_tests" || test -n "$inc_unportable_tests" \
+ || inc=false
+ ;;
+ *-test)
+ test -n "$inc_all_tests" \
+ || inc=false
+ ;;
+ esac
+ done
+ if ! $inc; then
+ return 1
+ fi
+ ;;
+ esac
return 0
}
# - inctests true if tests should be included, blank otherwise
# - incobsolete true if obsolete modules among dependencies should be
# included, blank otherwise
+# - inc_cxx_tests true if C++ interoperability tests should be included,
+# blank otherwise
+# - inc_longrunning_tests true if long-runnings tests should be included,
+# blank otherwise
+# - inc_privileged_tests true if tests that require root privileges should be
+# included, blank otherwise
+# - inc_unportable_tests true if tests that fail on some platforms should be
+# included, blank otherwise
+# - inc_all_tests true if all kinds of problematic unit tests should be
+# included, blank otherwise
# - avoidlist list of modules to avoid
# - tmp pathname of a temporary directory
# Output:
fi
for dep in $deps; do
if test -n "$incobsolete" \
- || { status=`func_get_status $dep`; test "$status" != obsolete; }; then
+ || { inc=true
+ for word in `func_get_status $dep`; do
+ case "$word" in
+ obsolete)
+ inc=false
+ ;;
+ esac
+ done
+ $inc
+ }; then
func_append inmodules " $dep"
fi
done
echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
}
-# func_emit_tests_Makefile_am
+# func_emit_tests_Makefile_am witness_macro
# emits the contents of tests makefile to standard output.
# Input:
# - local_gnulib_dir from --local-dir
# - uses_subdirs nonempty if object files in subdirs exist
func_emit_tests_Makefile_am ()
{
+ witness_macro="$1"
if test "$libtool" = true; then
libext=la
sed_eliminate_LDFLAGS="$sed_noop"
done
echo
echo "AM_CPPFLAGS = \\"
+ if test -n "${witness_macro}"; then
+ echo " -D@${witness_macro}@=1 \\"
+ fi
echo " -I. -I\$(srcdir) \\"
echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
# - auxdir directory relative to destdir where to place build aux files
# - inctests true if --with-tests was given, blank otherwise
# - incobsolete true if --with-obsolete was given, blank otherwise
+# - inc_cxx_tests true if --with-c++-tests was given, blank otherwise
+# - inc_longrunning_tests true if --with-longrunning-tests was given, blank
+# otherwise
+# - inc_privileged_tests true if --with-privileged-tests was given, blank
+# otherwise
+# - inc_unportable_tests true if --with-unportable-tests was given, blank
+# otherwise
+# - inc_all_tests true if --with-all-tests was given, blank otherwise
# - avoidlist list of modules to avoid, from --avoid
# - lgpl yes or a number if library's license shall be LGPL,
# blank otherwise
cached_local_gnulib_dir=
cached_specified_modules=
cached_incobsolete=
+ cached_inc_cxx_tests=
+ cached_inc_longrunning_tests=
+ cached_inc_privileged_tests=
+ cached_inc_unportable_tests=
+ cached_inc_all_tests=
cached_avoidlist=
cached_sourcebase=
cached_m4base=
/gl_WITH_OBSOLETE/ {
s,^.*$,cached_incobsolete=true,p
}
+ /gl_WITH_CXX_TESTS/ {
+ s,^.*$,cached_inc_cxx_tests=true,p
+ }
+ /gl_WITH_LONGRUNNING_TESTS/ {
+ s,^.*$,cached_inc_longrunning_tests=true,p
+ }
+ /gl_WITH_PRIVILEGED_TESTS/ {
+ s,^.*$,cached_inc_privileged_tests=true,p
+ }
+ /gl_WITH_UNPORTABLE_TESTS/ {
+ s,^.*$,cached_inc_unportable_tests=true,p
+ }
+ /gl_WITH_ALL_TESTS/ {
+ s,^.*$,cached_inc_all_tests=true,p
+ }
/gl_AVOID(/ {
s,^.*gl_AVOID([[ ]*\([^]"$`\\)]*\).*$,cached_avoidlist="\1",p
}
if test -z "$incobsolete"; then
incobsolete="$cached_incobsolete"
fi
+ # Included special kinds of tests modules among the dependencies if specified
+ # either way.
+ if test -z "$inc_cxx_tests"; then
+ inc_cxx_tests="$cached_inc_cxx_tests"
+ fi
+ if test -z "$inc_longrunning_tests"; then
+ inc_longrunning_tests="$cached_inc_longrunning_tests"
+ fi
+ if test -z "$inc_privileged_tests"; then
+ inc_privileged_tests="$cached_inc_privileged_tests"
+ fi
+ if test -z "$inc_unportable_tests"; then
+ inc_unportable_tests="$cached_inc_unportable_tests"
+ fi
+ if test -z "$inc_all_tests"; then
+ inc_all_tests="$cached_inc_all_tests"
+ fi
# Append the cached and the specified avoidlist. This is probably better
# than dropping the cached one when --avoid is specified at least once.
avoidlist=`for m in $cached_avoidlist $avoidlist; do echo $m; done | LC_ALL=C sort -u`
if test -n "$incobsolete"; then
func_append actioncmd " --with-obsolete"
fi
+ if test -n "$inc_cxx_tests"; then
+ func_append actioncmd " --with-c++-tests"
+ fi
+ if test -n "$inc_longrunning_tests"; then
+ func_append actioncmd " --with-longrunning-tests"
+ fi
+ if test -n "$inc_privileged_tests"; then
+ func_append actioncmd " --with-privileged-tests"
+ fi
+ if test -n "$inc_unportable_tests"; then
+ func_append actioncmd " --with-unportable-tests"
+ fi
+ if test -n "$inc_all_tests"; then
+ func_append actioncmd " --with-all-tests"
+ fi
for module in $avoidlist; do
func_append actioncmd " --avoid=$module"
done
echo "$specified_modules" | sed -e 's/^/ /g'
echo "])"
test -z "$incobsolete" || echo "gl_WITH_OBSOLETE"
+ test -z "$inc_cxx_tests" || echo "gl_WITH_CXX_TESTS"
+ test -z "$inc_longrunning_tests" || echo "gl_WITH_LONGRUNNING_TESTS"
+ test -z "$inc_privileged_tests" || echo "gl_WITH_PRIVILEGED_TESTS"
+ test -z "$inc_unportable_tests" || echo "gl_WITH_UNPORTABLE_TESTS"
+ test -z "$inc_all_tests" || echo "gl_WITH_ALL_TESTS"
echo "gl_AVOID([$avoidlist])"
echo "gl_SOURCE_BASE([$sourcebase])"
echo "gl_M4_BASE([$m4base])"
echo " gltests_ltlibdeps="
func_emit_initmacro_start ${macro_prefix}tests
echo " gl_source_base='$testsbase'"
+ # Define a tests witness macro that depends on the package.
+ # PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
+ # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
+ echo "changequote(,)dnl"
+ echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
+ echo "changequote([, ])dnl"
+ echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
+ echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
+ echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
for module in $testsrelated_modules; do
func_verify_module
if test -n "$module"; then
-e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
fi
done
+ echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
func_emit_initmacro_end ${macro_prefix}tests
# _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
# created using libtool, because libtool already handles the dependencies.
func_dest_tmpfilename $testsbase/$makefile_am
destfile="$testsbase/$makefile_am"
modules="$testsrelated_modules"
- func_emit_tests_Makefile_am > "$tmpfile"
+ func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
if test -f "$destdir"/$testsbase/$makefile_am; then
if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
rm -f "$tmpfile"
fi
modules=`for m in $modules; do echo $m; done | LC_ALL=C sort -u`
+ # Unlike in func_import, here we want to include all kinds of tests.
+ inc_all_tests=true
+
# Check that the license of every module is consistent with the license of
# its dependencies.
saved_modules="$modules"
# Create $testsbase/Makefile.am.
use_libtests=false
destfile="$testsbase/Makefile.am"
- func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
+ func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
# Create $testsbase/configure.ac.
(echo "# Process this file with autoconf to produce a configure script."
for m4base in $m4dirs; do
# Perform func_import in a subshell, so that variable values
# such as
- # local_gnulib_dir, incobsolete, avoidlist, sourcebase, m4base,
- # pobase, docbase, testsbase, inctests, libname, lgpl,
+ # local_gnulib_dir, incobsolete, inc_cxx_tests,
+ # inc_longrunning_tests, inc_privileged_tests,
+ # inc_unportable_tests, inc_all_tests, avoidlist, sourcebase,
+ # m4base, pobase, docbase, testsbase, inctests, libname, lgpl,
# makefile_name, libtool, macro_prefix, po_domain, vc_files
# don't propagate from one directory to another.
(func_import) || func_exit 1
done
;;
+ extract-comment )
+ for module
+ do
+ func_verify_module
+ if test -n "$module"; then
+ func_get_comment "$module"
+ fi
+ done
+ ;;
+
extract-status )
for module
do