Hi Simon, > > How about > > 1) change the default for --create-testdir so that it includes unportable > > or > > longrunning tests only for the modules explicitly listed on the command > > line, not for the dependencies? > > 2) adding options --without-unportable-tests etc.? > > > > Is this a good idea? > > I prefer only 1 because it appears to be sufficient here and results in > less complexity. We could adopt the philosophy that whatever > gnulib-tool ever generates should be portable unless the user supplied > any of the --with-*-tests flags. This results in this approach: > > * Change the default for --create-testdir so that it includes unportable or > longrunning tests only for the test modules explicitly listed on the > command > line, not for any dependencies -- unless the corresponding > --with-*-tests parameter is given.
Thanks for your feedback. I don't have a particular philosophy behind my opinion, just the practical wish that the long-running tests don't disturb me when I'm not interested in seeing their results. But I disagree about the need for --without-* flags. If gnulib-tool has a default policy that includes some categories of tests but not all, we need to provide an easy way to change that policy, in both directions: more tests and fewer tests. I'm applying these two patches. 2010-04-25 Bruno Haible <br...@clisp.org> gnulib-tool: Add --without-*-tests options. * gnulib-tool (func_usage): Document the --without-*-tests options. (excl_cxx_tests, excl_longrunning_tests, excl_privileged_tests, excl_unportable_tests): New variables. Fail if they are specified with --import or --update. (func_acceptable): Respect the excl_*_tests variables. (func_import): Set the excl_*_tests variables to empty. *** gnulib-tool.orig Sun Apr 25 13:32:18 2010 --- gnulib-tool Sun Apr 25 13:17:39 2010 *************** *** 247,252 **** --- 247,261 ---- (.gitignore and/or .cvsignore). --no-changelog Don't update or create ChangeLog files. + Options for --create-[mega]testdir, --[mega]test: + --without-c++-tests Exclude unit tests for C++ interoperability. + --without-longrunning-tests + Exclude unit tests that are long-runners. + --without-privileged-tests + Exclude unit tests that require root privileges. + --without-unportable-tests + Exclude unit tests that fail on some platforms. + Options for --import, --update, --create-[mega]testdir, --[mega]test: -s, --symbolic, --symlink Make symbolic links instead of copying files. --local-symlink Make symbolic links instead of copying files, only *************** *** 875,880 **** --- 884,896 ---- # - inc_unportable_tests true if --with-unportable-tests was given, blank # otherwise # - inc_all_tests true if --with-all-tests was given, blank otherwise + # - excl_cxx_tests true if --without-c++-tests was given, blank otherwise + # - excl_longrunning_tests true if --without-longrunning-tests was given, + # blank otherwise + # - excl_privileged_tests true if --without-privileged-tests was given, blank + # otherwise + # - excl_unportable_tests true if --without-unportable-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 *************** *** 912,917 **** --- 928,937 ---- inc_privileged_tests= inc_unportable_tests= inc_all_tests= + excl_cxx_tests= + excl_longrunning_tests= + excl_privileged_tests= + excl_unportable_tests= avoidlist= lgpl= makefile_name= *************** *** 1084,1089 **** --- 1104,1121 ---- --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 ;; + --without-c++-tests | --without-c++-test | --without-c++-tes | --without-c++-te | --without-c++-t | --without-c++- | --without-c++ | --without-c+ | --without-c) + excl_cxx_tests=true + shift ;; + --without-longrunning-tests | --without-longrunning-test | --without-longrunning-tes | --without-longrunning-te | --without-longrunning-t | --without-longrunning- | --without-longrunning | --without-longrunnin | --without-longrunni | --without-longrunn | --without-longrun | --without-longru | --without-longr | --without-long | --without-lon | --without-lo | --without-l) + excl_longrunning_tests=true + shift ;; + --without-privileged-tests | --without-privileged-test | --without-privileged-tes | --without-privileged-te | --without-privileged-t | --without-privileged- | --without-privileged | --without-privilege | --without-privileg | --without-privile | --without-privil | --without-privi | --without-priv | --without-pri | --without-pr | --without-p) + excl_privileged_tests=true + shift ;; + --without-unportable-tests | --without-unportable-test | --without-unportable-tes | --without-unportable-te | --without-unportable-t | --without-unportable- | --without-unportable | --without-unportabl | --without-unportab | --without-unporta | --without-unport | --without-unpor | --without-unpo | --without-unp | --without-un | --without-u) + excl_unportable_tests=true + shift ;; --avoid ) shift if test $# = 0; then *************** *** 1183,1188 **** --- 1215,1228 ---- esac done + if test "$mode" = import; then + if test -n "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \ + || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests"; then + echo "gnulib-tool: invalid options for 'import' mode" 1>&2 + echo "Try 'gnulib-tool --help' for more information." 1>&2 + func_exit 1 + fi + fi if test "$mode" = update; then if test $# != 0; then echo "gnulib-tool: too many arguments in 'update' mode" 1>&2 *************** *** 1198,1203 **** --- 1238,1245 ---- || 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 "$excl_cxx_tests" || test -n "$excl_longrunning_tests" \ + || test -n "$excl_privileged_tests" || test -n "$excl_unportable_tests" \ || test -n "$avoidlist" || test -n "$lgpl" || test -n "$makefile_name" \ || test -n "$macro_prefix" || test -n "$po_domain" \ || test -n "$vc_files"; then *************** *** 2296,2301 **** --- 2338,2351 ---- # included, blank otherwise # - inc_all_tests true if all kinds of problematic unit tests should be # included, blank otherwise + # - excl_cxx_tests true if C++ interoperability tests should be excluded, + # blank otherwise + # - excl_longrunning_tests true if long-runnings tests should be excluded, + # blank otherwise + # - excl_privileged_tests true if tests that require root privileges should be + # excluded, blank otherwise + # - excl_unportable_tests true if tests that fail on some platforms should be + # excluded, blank otherwise # - avoidlist list of modules to avoid func_acceptable () { *************** *** 2310,2327 **** --- 2360,2385 ---- for word in `func_get_status "$1"`; do case "$word" in c++-test) + test -z "$excl_cxx_tests" \ + || inc=false test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \ || inc=false ;; longrunning-test) + test -z "$excl_longrunning_tests" \ + || inc=false test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \ || inc=false ;; privileged-test) + test -z "$excl_privileged_tests" \ + || inc=false test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \ || inc=false ;; unportable-test) + test -z "$excl_unportable_tests" \ + || inc=false test -n "$inc_all_tests" || test -n "$inc_unportable_tests" \ || inc=false ;; *************** *** 2357,2362 **** --- 2415,2428 ---- # included, blank otherwise # - inc_all_tests true if all kinds of problematic unit tests should be # included, blank otherwise + # - excl_cxx_tests true if C++ interoperability tests should be excluded, + # blank otherwise + # - excl_longrunning_tests true if long-runnings tests should be excluded, + # blank otherwise + # - excl_privileged_tests true if tests that require root privileges should be + # excluded, blank otherwise + # - excl_unportable_tests true if tests that fail on some platforms should be + # excluded, blank otherwise # - avoidlist list of modules to avoid # - tmp pathname of a temporary directory # Output: *************** *** 3460,3465 **** --- 3526,3536 ---- if test -z "$inc_all_tests"; then inc_all_tests="$cached_inc_all_tests" fi + # --without-*-tests options are not supported here. + excl_cxx_tests= + excl_longrunning_tests= + excl_privileged_tests= + excl_unportable_tests= # 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` *************** *** 4661,4666 **** --- 4732,4745 ---- # - inctests true if tests should be included, blank otherwise # - incobsolete true if obsolete modules among dependencies should be # included, blank otherwise + # - excl_cxx_tests true if C++ interoperability tests should be excluded, + # blank otherwise + # - excl_longrunning_tests true if long-runnings tests should be excluded, + # blank otherwise + # - excl_privileged_tests true if tests that require root privileges should be + # excluded, blank otherwise + # - excl_unportable_tests true if tests that fail on some platforms should be + # excluded, blank otherwise # - avoidlist list of modules to avoid # - libtool true if --libtool was given, false if --no-libtool was # given, blank otherwise 2010-04-25 Bruno Haible <br...@clisp.org> gnulib-tool: Don't include hairy tests of dependencies in testdirs. * gnulib-tool (func_usage): Document that --with-*-tests options apply also to --create-testdir. (func_acceptable): Don't consider the status of *-tests modules here. (func_modules_transitive_closure): Consider it here, before including a test module. (func_import, func_create_testdir): Set inc_all_direct_tests, inc_all_indirect_tests. * doc/gnulib.texi (Extra tests modules): Document new behaviour of --create-testdir and --create-megatestdir. diff --git a/doc/gnulib.texi b/doc/gnulib.texi index 74499b5..62f969e 100644 --- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -739,8 +739,16 @@ When @code{gnulib-tool} receives the option @code{--with-all-tests}, it will include all tests regardless of their status attributes. @code{gnulib-tool --create-testdir} and -...@code{gnulib-tool --create-megatestdir} always include all tests -regardless of their status attributes. +...@code{gnulib-tool --create-megatestdir} by default include all tests of +modules specified on the command line, regardless of their status +attributes. Tests of modules occurring as dependencies are not included +by default if they have one of these status attributes. The options +...@code{--with-c++-tests}, @code{--with-longrunning-tests}, +...@code{--with-privileged-tests}, @code{--with-unportable-tests} are +recognized here as well. Additionally, @code{gnulib-tool} also +understands the options @code{--without-c++-tests}, +...@code{--without-longrunning-tests}, @code{--without-privileged-tests}, +...@code{--without-unportable-tests}. In order to mark a module with a status attribute, you need to add it to the module description, like this: diff --git a/gnulib-tool b/gnulib-tool index 57079a0..1902c5c 100755 --- a/gnulib-tool +++ b/gnulib-tool @@ -200,6 +200,15 @@ Options for --import, --create-[mega]testdir, --[mega]test: --with-obsolete Include obsolete modules when they occur among the dependencies. By default, dependencies to obsolete modules are ignored. + --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. --avoid=MODULE Avoid including the given MODULE. Useful if you have code that provides equivalent functionality. This option can be repeated. @@ -233,15 +242,6 @@ Options for --import: '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). @@ -2328,24 +2328,6 @@ func_get_tests_module () # 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 -# - excl_cxx_tests true if C++ interoperability tests should be excluded, -# blank otherwise -# - excl_longrunning_tests true if long-runnings tests should be excluded, -# blank otherwise -# - excl_privileged_tests true if tests that require root privileges should be -# excluded, blank otherwise -# - excl_unportable_tests true if tests that fail on some platforms should be -# excluded, blank otherwise # - avoidlist list of modules to avoid func_acceptable () { @@ -2354,46 +2336,6 @@ 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 -z "$excl_cxx_tests" \ - || inc=false - test -n "$inc_all_tests" || test -n "$inc_cxx_tests" \ - || inc=false - ;; - longrunning-test) - test -z "$excl_longrunning_tests" \ - || inc=false - test -n "$inc_all_tests" || test -n "$inc_longrunning_tests" \ - || inc=false - ;; - privileged-test) - test -z "$excl_privileged_tests" \ - || inc=false - test -n "$inc_all_tests" || test -n "$inc_privileged_tests" \ - || inc=false - ;; - unportable-test) - test -z "$excl_unportable_tests" \ - || inc=false - 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 } @@ -2413,8 +2355,12 @@ func_acceptable () # 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 +# - inc_all_direct_tests true if all kinds of problematic unit tests among +# the unit tests of the specified modules should be +# included, blank otherwise +# - inc_all_indirect_tests true if all kinds of problematic unit tests among +# the unit tests of the dependencies should be +# included, blank otherwise # - excl_cxx_tests true if C++ interoperability tests should be excluded, # blank otherwise # - excl_longrunning_tests true if long-runnings tests should be excluded, @@ -2437,6 +2383,7 @@ func_modules_transitive_closure () handledmodules= inmodules="$modules" outmodules= + fmtc_inc_all_tests="$inc_all_direct_tests" while test -n "$inmodules"; do inmodules_this_round="$inmodules" inmodules= # Accumulator, queue for next round @@ -2469,7 +2416,43 @@ func_modules_transitive_closure () if test -n "$inctests"; then testsmodule=`func_get_tests_module $module` if test -n "$testsmodule"; then - func_append inmodules " $testsmodule" + # Determine whether to include the tests module. + inc=true + for word in `func_get_status "$testsmodule"`; do + case "$word" in + c++-test) + test -z "$excl_cxx_tests" \ + || inc=false + test -n "$fmtc_inc_all_tests" || test -n "$inc_cxx_tests" \ + || inc=false + ;; + longrunning-test) + test -z "$excl_longrunning_tests" \ + || inc=false + test -n "$fmtc_inc_all_tests" || test -n "$inc_longrunning_tests" \ + || inc=false + ;; + privileged-test) + test -z "$excl_privileged_tests" \ + || inc=false + test -n "$fmtc_inc_all_tests" || test -n "$inc_privileged_tests" \ + || inc=false + ;; + unportable-test) + test -z "$excl_unportable_tests" \ + || inc=false + test -n "$fmtc_inc_all_tests" || test -n "$inc_unportable_tests" \ + || inc=false + ;; + *-test) + test -n "$fmtc_inc_all_tests" \ + || inc=false + ;; + esac + done + if $inc; then + func_append inmodules " $testsmodule" + fi fi fi fi @@ -2479,6 +2462,7 @@ func_modules_transitive_closure () # Remove $handledmodules from $inmodules. for m in $inmodules; do echo $m; done | LC_ALL=C sort -u > "$tmp"/queued-modules inmodules=`echo "$handledmodules" | LC_ALL=C join -v 2 - "$tmp"/queued-modules` + fmtc_inc_all_tests="$inc_all_indirect_tests" done modules=`for m in $outmodules; do echo $m; done | LC_ALL=C sort -u` rm -f "$tmp"/queued-modules @@ -3607,6 +3591,10 @@ func_import () # Canonicalize the list of specified modules. specified_modules=`for m in $specified_modules; do echo $m; done | LC_ALL=C sort -u` + # Include all kinds of tests modules if --with-all-tests was specified. + inc_all_direct_tests="$inc_all_tests" + inc_all_indirect_tests="$inc_all_tests" + # Determine final module list. modules="$specified_modules" func_modules_transitive_closure @@ -4760,8 +4748,10 @@ func_create_testdir () 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 + # Unlike in func_import, here we want to include all kinds of tests for the + # directly specified modules, but not for dependencies. + inc_all_direct_tests=true + inc_all_indirect_tests="$inc_all_tests" # Check that the license of every module is consistent with the license of # its dependencies.