Sometimes it is useful to have, in your package, only a few hand-picked tests, not all tests in the transitive closure of the imported gnulib modules.
For example, when the package creates a library with a limited set of exported symbols, most gnulib tests would access symbols that are not exported from the library. Using --avoid would be too unmaintainable, since the set of tests computed by the transitive closure algorithm is subject to change without notice. This patch implements this possibility. 2019-02-15 Bruno Haible <br...@clisp.org> gnulib-tool: Support --import with just a few tests, not --with-tests. * gnulib-tool (func_import): New variable 'gentests'. Use it instead of 'inctests' when generating files; use 'inctests' only for computing the transitive closure. diff --git a/gnulib-tool b/gnulib-tool index 3dc9a1d..34d198f 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -5107,6 +5107,14 @@ s,^\(.................................................[^ ]*\) *, s,^top/,$rewritten, s,^$rewritten,," + # Determine whether to put anything into $testsbase. + testsfiles=`echo "$files" | sed -n -e 's,^tests/,,p' -e 's,^tests=lib/,,p'` + if test -n "$testsfiles"; then + gentests=true + else + gentests=false + fi + # Create directories. { echo "$sourcebase" echo "$m4base" @@ -5117,7 +5125,7 @@ s,^\(.................................................[^ ]*\) *, if test -n "$docfiles"; then echo "$docbase" fi - if $inctests; then + if $gentests; then echo "$testsbase" fi echo "$auxdir" @@ -5412,7 +5420,7 @@ s,//*$,/,' && ! { test -f "${destdir}/${dir1}Makefile.am" \ || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \ || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \ - || { $inctests \ + || { $gentests \ && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \ || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2" @@ -5833,7 +5841,7 @@ s,//*$,/,' fi fi - if $inctests; then + if $gentests; then # Create tests makefile. func_dest_tmpfilename $testsbase/$makefile_am destfile="$testsbase/$makefile_am" @@ -6021,7 +6029,7 @@ s,//*$,/,' if test -n "$pobase"; then echo " - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac," fi - if $inctests; then + if $gentests; then if test "$makefile_am" = Makefile.am; then echo " - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac," else