gnulib-tool: Add support for special categories of tests.
authorBruno Haible <bruno@clisp.org>
Sun, 28 Mar 2010 16:01:18 +0000 (18:01 +0200)
committerBruno Haible <bruno@clisp.org>
Sun, 28 Mar 2010 16:01:18 +0000 (18:01 +0200)
ChangeLog
doc/gnulib.texi
gnulib-tool

index e1f2a1e..bdbe8bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,23 @@
 2010-03-28  Bruno Haible  <bruno@clisp.org>
 
+       gnulib-tool: Add support for special categories of tests.
+       * gnulib-tool: New options --with-c++-tests, --with-longrunning-tests,
+       --with-privileged-tests, --with-unportable-tests, --with-all-tests.
+       (func_usage): Document them.
+       (inc_cxx_tests, inc_longrunning_tests, inc_privileged_tests,
+       inc_unportable_tests, inc_all_tests): New variables.
+       (func_acceptable): Consider these variables.
+       (func_modules_transitive_closure): Make it work when the 'Status' field
+       consists of multiple words.
+       (func_import): Store and restore the values of inc_cxx_tests,
+       inc_longrunning_tests, inc_privileged_tests, inc_unportable_tests,
+       inc_all_tests in gnulib-comp.m4.
+       (func_create_testdir): Set inc_all_tests to true.
+       * doc/gnulib.texi (Extra tests modules): New section.
+       Suggested by Jim Meyering.
+
+2010-03-28  Bruno Haible  <bruno@clisp.org>
+
        ansi-c++-opt: Allow turning off the C++ build by default.
        * m4/ansi-c++.m4 (gl_CXX_CHOICE): Let CXX_CHOICE default to 'no' if
        gl_CXX_CHOICE_DEFAULT_NO is defined.
index 7903605..a947dbf 100644 (file)
@@ -614,6 +614,7 @@ before every release.
 @menu
 * Out of memory handling::
 * Obsolete modules::
+* Extra tests modules::
 * A C++ namespace for gnulib::      A different way of using Gnulib in C++
 * Library version handling::
 * Windows sockets::
@@ -689,6 +690,67 @@ This module is obsolete.
 @end example
 
 
+@node Extra tests modules
+@section Extra tests modules
+
+@cindex Extra tests modules
+@cindex C++ tests modules
+@cindex tests modules, C++
+@cindex long-running tests modules
+@cindex tests modules, long-running
+@cindex privileged tests modules
+@cindex tests modules, privileged
+@cindex unportable tests modules
+@cindex tests modules, unportable
+Test modules can be marked with some special status attributes.  When a
+test module has such an attribute, @code{gnulib-tool --import} will not
+include it by default.
+
+The supported status attributes are:
+
+@table @code
+@item c++-test
+Indicates that the test is testing C++ interoperability.  Such a test is
+useful in a C++ or mixed C/C++ package, but is useless in a C package.
+
+@item longrunning-test
+Indicates that the test takes a long time to compile or execute (more
+than five minutes or so).  Such a test is better avoided in a release
+that is made for the general public.
+
+@item privileged-test
+Indicates that the test will request special privileges, for example,
+ask for the superuser password.  Such a test may hang when run
+non-interactively and is therefore better avoided in a release that is
+made for the general public.
+
+@item unportable-test
+Indicates that the test is known to fail on some systems, and that
+there is no workaround about it.  Such a test is better avoided in a
+release that is made for the general public.
+@end table
+
+@code{gnulib-tool --import} will not include tests marked with these
+attributes by default.  When @code{gnulib-tool} is invoked with one
+of the options @code{--with-c++-tests}, @code{--with-longrunning-tests},
+@code{--with-privileged-tests}, @code{--with-unportable-tests}, it
+will include tests despite the corresponding special status attribute.
+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.
+
+In order to mark a module with a status attribute, you need to add it
+to the module description, like this:
+
+@example
+Status:
+longrunning-test
+@end example
+
+
 @node A C++ namespace for gnulib
 @section A C++ namespace for gnulib
 
index b314dc5..99abb62 100755 (executable)
@@ -165,7 +165,7 @@ Operation modes:
                             (recommended to use CC=\"gcc -Wall\" here)
       --extract-description        extract the description
       --extract-comment            extract the comment
-      --extract-status             extract the status (obsolete or not)
+      --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
@@ -233,6 +233,15 @@ 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).
@@ -858,6 +867,14 @@ fi
 # - 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
@@ -890,6 +907,11 @@ fi
   auxdir=
   inctests=
   incobsolete=
+  inc_cxx_tests=
+  inc_longrunning_tests=
+  inc_privileged_tests=
+  inc_unportable_tests=
+  inc_all_tests=
   avoidlist=
   lgpl=
   makefile_name=
@@ -1041,12 +1063,27 @@ fi
       --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
@@ -1158,6 +1195,9 @@ fi
        || 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
@@ -2235,6 +2275,16 @@ 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
 # - avoidlist       list of modules to avoid
 func_acceptable ()
 {
@@ -2243,6 +2293,38 @@ 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
 }
 
@@ -2254,6 +2336,16 @@ func_acceptable ()
 # - 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:
@@ -2284,7 +2376,16 @@ func_modules_transitive_closure ()
           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
@@ -3127,6 +3228,14 @@ func_emit_initmacro_done ()
 # - 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
@@ -3151,6 +3260,11 @@ func_import ()
   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=
@@ -3188,6 +3302,21 @@ func_import ()
       /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
       }
@@ -3287,6 +3416,23 @@ func_import ()
   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`
@@ -3753,6 +3899,21 @@ s,^\(.................................................[^ ]*\) *,
   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
@@ -4039,6 +4200,11 @@ s,//*$,/,'
     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])"
@@ -4485,6 +4651,9 @@ 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
+
   # Check that the license of every module is consistent with the license of
   # its dependencies.
   saved_modules="$modules"
@@ -5228,8 +5397,10 @@ s/\([.*$]\)/[\1]/g'
             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