Bruno Haible | 20 Jun 2012 23:22

parse-duration test output

Hi Bruce,

$ ./gnulib-tool --test --with-tests parse-duration
produces as part of the unit test output (on glibc/Linux with bash 4.2
and other platforms):

../../gltests/test-parse-duration.sh: line 68: warning: here-document at line 52 delimited by
end-of-file (wanted `_EOF_')
could not parse time:  
        err 22 - Invalid argument
PASS: test-parse-duration.sh

Can you please fix this? Gnulib unit tests should normally not
produce output when they pass.

Bruno

Bruce Korb | 20 Jun 2012 23:29
Picon

Re: parse-duration test output

Sure.  Thank you.  I am away from where I can play with the stuff for
a couple of days, so likely this weekend....

On Wed, Jun 20, 2012 at 2:22 PM, Bruno Haible <bruno <at> clisp.org> wrote:
> Hi Bruce,
>
> $ ./gnulib-tool --test --with-tests parse-duration
> produces as part of the unit test output (on glibc/Linux with bash 4.2
> and other platforms):
>
> ../../gltests/test-parse-duration.sh: line 68: warning: here-document at line 52 delimited by
end-of-file (wanted `_EOF_')
> could not parse time:
>        err 22 - Invalid argument
> PASS: test-parse-duration.sh
>
> Can you please fix this? Gnulib unit tests should normally not
> produce output when they pass.
>
> Bruno
>

Simon Josefsson | 21 Jun 2012 05:37
Favicon
Gravatar

gnulib-tool and --with-tests

Bruno Haible <bruno <at> clisp.org> writes:

> $ ./gnulib-tool --test --with-tests parse-duration

Using '--test --with-tests' or '--create-testdir --with-tests' is quite
common.  Is there any reason why --with-tests isn't the default?  It
seems rare to want to test a module without also wanting to include its
self-tests.  Naively, it also seems surprising that '--test' and
'-create-testdir' does not bring in self-*tests*.

What do you think of making --with-tests a no-op, and add a
--without-tests to disable it?  This would save us all some typing...

I haven't looked into the gnulib-tool changes at all so I don't know how
difficult it would be to implement.

/Simon

Bruno Haible | 21 Jun 2012 11:30

Re: gnulib-tool and --with-tests

Hi Simon,

> > $ ./gnulib-tool --test --with-tests parse-duration
> 
> Using '--test --with-tests' or '--create-testdir --with-tests' is quite
> common.  Is there any reason why --with-tests isn't the default?

It's for consistency with --import. Many packages like to have --import
without tests, and having --with-tests be enabled for --test but not for
--import would/may seem odd.

Maybe it's also historical: when the core of gnulib-tool was written
(in August 2004), gnulib did not contain any unit tests, but the option
--create-testdir exists already since 2002. Support for unit test modules
was only added on 2005-08-25.

> It seems rare to want to test a module without also wanting to include its
> self-tests.  Naively, it also seems surprising that '--test' and
> '-create-testdir' does not bring in self-*tests*.

I agree.

> What do you think of making --with-tests a no-op, and add a
> --without-tests to disable it?  This would save us all some typing...

You mean to make this change only in combination with --test,
--create-testdir, and --create-megatestdir? Not with --import.

I'm undecided. What do the others think?

(Continue reading)

Ben Pfaff | 21 Jun 2012 18:20
Picon

Re: gnulib-tool and --with-tests

Bruno Haible <bruno <at> clisp.org> writes:

>> What do you think of making --with-tests a no-op, and add a
>> --without-tests to disable it?  This would save us all some typing...
>
> You mean to make this change only in combination with --test,
> --create-testdir, and --create-megatestdir? Not with --import.
>
> I'm undecided. What do the others think?

I've always found it surprising that creating a test directory
didn't include the tests.  I remember to use --with-tests these
days, but I think that having that be the default would be less
surprising.

Paul Eggert | 21 Jun 2012 18:55
Favicon

Re: gnulib-tool and --with-tests

On 06/21/2012 09:20 AM, Ben Pfaff wrote:
> I remember to use --with-tests these
> days, but I think that having that be the default would be less
> surprising.

My sentiments exactly.  I think the current behavior surprises
pretty much every new gnulib-tool user, and I like the idea of
having --with-tests be the default if --test is used.

Dmitriy Selyutin | 21 Jun 2012 19:48
Picon

Re: gnulib-tool and --with-tests

Hello everyone!

If we decide to use such behavior as default, I'll now add this feature to Python version when I begin to write GNULibTest class.

Bruno Haible | 21 Jun 2012 22:47

Re: gnulib-tool and --with-tests

Hello Dmitriy,

> If we decide to use such behavior as default, I'll now add this feature to
> Python version when I begin to write GNULibTest class.

Yes, please. This is very welcome.

Note that the change affects only the default value for the 4 modes
--create-[mega]testdir and --[mega]test. Nothing changes for --import.

Bruno

Dmitriy Selyutin | 22 Jun 2012 00:14
Picon

Re: gnulib-tool and --with-tests

Hi Bruni,

>> Yes, please. This is very welcome.

OK, I'll add it when I begin to write code for GNULibTests class. It is very good that I didn't miss this letter. :-)

Bruno Haible | 21 Jun 2012 22:46

Re: gnulib-tool and --with-tests

Paul Eggert and Ben Pfaff wrote:
> I think the current behavior surprises
> pretty much every new gnulib-tool user, and I like the idea of
> having --with-tests be the default if --test is used.

Thanks for the vote. I think you have a majority. So I am applying this
change, followed by a no-op refactoring.

2012-06-21  Bruno Haible  <bruno <at> clisp.org>

	gnulib-tool: --create-[mega]testdir, --[mega]test implies --with-tests.
	* gnulib-tool: Accept option --without-tests.
	(func_usage): Document --without-tests option. Rearrange.
	(inctests): Normalize according to the mode.
	* NEWS: Mention the change.
	Suggested by Simon Josefsson.

--- NEWS.orig	Thu Jun 21 22:22:23 2012
+++ NEWS	Thu Jun 21 22:22:15 2012
 <at>  <at>  -3,6 +3,10  <at>  <at> 

 Date        Modules         Changes

+2012-06-21  gnulib-tool     The option --with-tests is now implied by the
+                            options --create-testdir, --test,
+                            --create-megatestdir, --megatest.
+
 2012-01-07  quotearg        In the C locale, the function will no longer use
                             the grave accent character to begin a quoted
                             string (`like this').  It will use apostrophes
--- gnulib-tool.orig	Thu Jun 21 22:22:23 2012
+++ gnulib-tool	Thu Jun 21 22:10:24 2012
 <at>  <at>  -164,15 +164,11  <at>  <at> 
       --update              update the current package, restore files omitted
                             from version control
       --create-testdir      create a scratch package with the given modules
-                            (pass --with-tests to include the unit tests)
       --create-megatestdir  create a mega scratch package with the given modules
                             one by one and all together
-                            (pass --with-tests to include the unit tests)
       --test                test the combination of the given modules
-                            (pass --with-tests to include the unit tests)
                             (recommended to use CC=\"gcc -Wall\" here)
       --megatest            test the given modules one by one and all together
-                            (pass --with-tests to include the unit tests)
                             (recommended to use CC=\"gcc -Wall\" here)
       --extract-description        extract the description
       --extract-comment            extract the comment
 <at>  <at>  -210,21 +206,35  <at>  <at> 

       --dry-run             Only print what would have been done.

+Options for --import, --add/remove-import:
+
+      --with-tests          Include unit tests for the included modules.
+
+Options for --create-[mega]testdir, --[mega]test:
+
+      --without-tests       Don't include unit tests for the included modules.
+
 Options for --import, --add/remove-import,
             --create-[mega]testdir, --[mega]test:

-      --with-tests          Include unit tests for the included modules.
       --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.
+      --without-c++-tests   Exclude unit tests for C++ interoperability.
       --with-longrunning-tests
                             Include even unit tests that are long-runners.
+      --without-longrunning-tests
+                            Exclude unit tests that are long-runners.
       --with-privileged-tests
                             Include even unit tests that require root
                             privileges.
+      --without-privileged-tests
+                            Exclude unit tests that require root privileges.
       --with-unportable-tests
                             Include even unit tests that fail on some platforms.
+      --without-unportable-tests
+                            Exclude 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.
 <at>  <at>  -274,13 +284,6  <at>  <at> 

 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.
       --single-configure    Generate a single configure file, not a separate
                             configure file for the tests directory.

 <at>  <at>  -908,8 +911,9  <at>  <at> 

 # Command-line option processing.
 # Removes the OPTIONS from the arguments. Sets the variables:
-# - mode            list or import or add-import or remove-import or update
-#                   or create-testdir or create-megatestdir
+# - mode            one of: list, find, import, add-import, remove-import,
+#                   update, create-testdir, create-megatestdir, test, megatest,
+#                   copy-file
 # - destdir         from --dir
 # - local_gnulib_dir  from --local-dir
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 <at>  <at>  -921,7 +925,8  <at>  <at> 
 # - docbase         from --doc-base
 # - testsbase       from --tests-base
 # - auxdir          from --aux-dir
-# - inctests        true if --with-tests was given, blank otherwise
+# - inctests        true if --with-tests was given, false if --without-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
 <at>  <at>  -1164,6 +1169,9  <at>  <at> 
       --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-tests | --without-test | --without-tes | --without-te | --without-t)
+        inctests=false
+        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 ;;
 <at>  <at>  -1339,6 +1347,23  <at>  <at> 
   if test -z "$pobase" && test -n "$po_domain"; then
     func_warning "--po-domain has no effect without a --po-base option"
   fi
+  # Canonicalize the inctests variable.
+  case "$mode" in
+    import | add-import | remove-import)
+      if test -z "$inctests"; then
+        inctests=false
+      fi
+      ;;
+    create-testdir | create-megatestdir | test | megatest)
+      if test -z "$inctests"; then
+        inctests=true
+      fi
+      ;;
+  esac
+  if test "$inctests" = false; then
+    inctests=""
+  fi
+  # Now the only possible values of "$inctests" are true and the empty string.
   if test "$cond_dependencies" = true && test -n "$inctests"; then
     echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
     func_exit 1

2012-06-21  Bruno Haible  <bruno <at> clisp.org>

	gnulib-tool: Refactor inctests variable.
	* gnulib-tool: Normalize inctests to 'true' or 'false', not ''.
	(func_modules_transitive_closure,
	func_modules_transitive_closure_separately,
	func_import, func_create_testdir): Update.

--- gnulib-tool.orig	Thu Jun 21 22:42:11 2012
+++ gnulib-tool	Thu Jun 21 22:42:08 2012
 <at>  <at>  -1360,11 +1360,9  <at>  <at> 
       fi
       ;;
   esac
-  if test "$inctests" = false; then
-    inctests=""
-  fi
-  # Now the only possible values of "$inctests" are true and the empty string.
-  if test "$cond_dependencies" = true && test -n "$inctests"; then
+  # Now the only possible values of "$inctests" are true and false
+  # (or blank but then it is irrelevant).
+  if test "$cond_dependencies" = true && test "$inctests" = true; then
     echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
     func_exit 1
   fi
 <at>  <at>  -2637,7 +2635,7  <at>  <at> 
 # - local_gnulib_dir  from --local-dir
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 # - modules         list of specified modules
-# - inctests        true if tests should be included, blank otherwise
+# - inctests        true if tests should be included, false otherwise
 # - incobsolete     true if obsolete modules among dependencies should be
 #                   included, blank otherwise
 # - inc_cxx_tests   true if C++ interoperability tests should be included,
 <at>  <at>  -2722,7 +2720,7  <at>  <at> 
           if test -n "$duplicated_deps"; then
             func_warning "module $module has duplicated dependencies: "`echo $duplicated_deps`
           fi
-          if test -n "$inctests"; then
+          if $inctests; then
             testsmodule=`func_get_tests_module $module`
             if test -n "$testsmodule"; then
               deps="$deps $testsmodule"
 <at>  <at>  -2845,7 +2843,7  <at>  <at> 
 # - local_gnulib_dir  from --local-dir
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 # - specified_modules  list of specified modules
-# - inctests        true if tests should be included, blank otherwise
+# - inctests        true if tests should be included, false otherwise
 # - incobsolete     true if obsolete modules among dependencies should be
 #                   included, blank otherwise
 # - inc_cxx_tests   true if C++ interoperability tests should be included,
 <at>  <at>  -2883,7 +2881,7  <at>  <at> 
 {
   # Determine main module list.
   saved_inctests="$inctests"
-  inctests=""
+  inctests=false
   modules="$specified_modules"
   func_modules_transitive_closure
   main_modules="$modules"
 <at>  <at>  -4100,7 +4098,7  <at>  <at> 
 # - docbase         directory relative to destdir where to place doc files
 # - testsbase       directory relative to destdir where to place unit test code
 # - auxdir          directory relative to destdir where to place build aux files
-# - inctests        true if --with-tests was given, blank otherwise
+# - inctests        true if --with-tests was given, false 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
 <at>  <at>  -4394,8 +4392,11  <at>  <at> 
       fi
     fi
     # Require the tests if specified either way.
-    if test -z "$inctests"; then
+    if ! $inctests; then
       inctests="$cached_inctests"
+      if test -z "$inctests"; then
+        inctests=false
+      fi
     fi
     # The libname defaults to the cached one.
     if test -z "$supplied_libname"; then
 <at>  <at>  -4444,7 +4445,7  <at>  <at> 
       vc_files="$cached_vc_files"
     fi
     # Ensure constraints.
-    if test "$cond_dependencies" = true && test -n "$inctests"; then
+    if test "$cond_dependencies" = true && $inctests; then
       echo "gnulib-tool: option --conditional-dependencies is not supported with --with-tests" 1>&2
       func_exit 1
     fi
 <at>  <at>  -4641,7 +4642,7  <at>  <at> 
     if test -n "$docfiles"; then
       echo "$docbase"
     fi
-    if test -n "$inctests"; then
+    if $inctests; then
       echo "$testsbase"
     fi
     echo "$auxdir"
 <at>  <at>  -4790,7 +4791,7  <at>  <at> 
   func_append actioncmd " --doc-base=$docbase"
   func_append actioncmd " --tests-base=$testsbase"
   func_append actioncmd " --aux-dir=$auxdir"
-  if test -n "$inctests"; then
+  if $inctests; then
     func_append actioncmd " --with-tests"
   fi
   if test -n "$incobsolete"; then
 <at>  <at>  -4887,7 +4888,7  <at>  <at> 
     pobase_base=`basename "$pobase"`
     func_note_Makefile_am_edit "$pobase_dir" SUBDIRS "$pobase_base"
   fi
-  if test -n "$inctests"; then
+  if $inctests; then
     if test "$makefile_am" = Makefile.am; then
       testsbase_dir=`echo "$testsbase" | sed -n -e 's,/[^/]*$,/,p'`
       testsbase_base=`basename "$testsbase"`
 <at>  <at>  -4906,7 +4907,7  <at>  <at> 
           && ! { test -f "${destdir}/${dir1}Makefile.am" \
                  || test "${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
                  || test "./${dir1}Makefile.am" = "$sourcebase/$makefile_am" \
-                 || { test -n "$inctests" \
+                 || { $inctests \
                       && { test "${dir1}Makefile.am" = "$testsbase/$makefile_am" \
                            || test "./${dir1}Makefile.am" = "$testsbase/$makefile_am"; }; }; }; do
       dir2=`echo "$dir1" | sed -e "$sed_last"`"$dir2"
 <at>  <at>  -5119,7 +5120,9  <at>  <at> 
     echo "gl_PO_BASE([$pobase])"
     echo "gl_DOC_BASE([$docbase])"
     echo "gl_TESTS_BASE([$testsbase])"
-    test -z "$inctests" || echo "gl_WITH_TESTS"
+    if $inctests; then
+      echo "gl_WITH_TESTS"
+    fi
     echo "gl_LIB([$libname])"
     if test -n "$lgpl"; then
       if test "$lgpl" = yes; then
 <at>  <at>  -5310,7 +5313,7  <at>  <at> 
     fi
   fi

-  if test -n "$inctests"; then
+  if $inctests; then
     # Create tests makefile.
     func_dest_tmpfilename $testsbase/$makefile_am
     destfile="$testsbase/$makefile_am"
 <at>  <at>  -5498,7 +5501,7  <at>  <at> 
   if test -n "$pobase"; then
     echo "  - add \"$pobase/Makefile.in\" to AC_CONFIG_FILES in $configure_ac,"
   fi
-  if test -n "$inctests"; then
+  if $inctests; then
     if test "$makefile_am" = Makefile.am; then
       echo "  - add \"$testsbase/Makefile\" to AC_CONFIG_FILES in $configure_ac,"
     else
 <at>  <at>  -5533,7 +5536,7  <at>  <at> 
 # - local_gnulib_dir  from --local-dir
 # - modcache        true or false, from --cache-modules/--no-cache-modules
 # - auxdir          directory relative to destdir where to place build aux files
-# - inctests        true if tests should be included, blank otherwise
+# - inctests        true if tests should be included, false otherwise
 # - incobsolete     true if obsolete modules among dependencies should be
 #                   included, blank otherwise
 # - excl_cxx_tests   true if C++ interoperability tests should be excluded,
 <at>  <at>  -5582,7 +5585,7  <at>  <at> 
   # When computing transitive closures, don't consider $module to depend on
   # $module-tests. Need this because tests are implicitly GPL and may depend
   # on GPL modules - therefore we don't want a warning in this case.
-  inctests=""
+  inctests=false
   for requested_module in $specified_modules; do
     requested_license=`func_get_license "$requested_module"`
     if test "$requested_license" != GPL; then
 <at>  <at>  -5784,7 +5787,7  <at>  <at> 
     func_append subdirs " po"
   fi

-  if test -n "$inctests"; then
+  if $inctests; then
     test -d "$testdir/$testsbase" || mkdir "$testdir/$testsbase"
     if $single_configure; then
       # Create $testsbase/Makefile.am.
 <at>  <at>  -6057,7 +6060,7  <at>  <at> 
    func_execute_command ${AUTOHEADER} || func_exit 1
    func_execute_command ${AUTOMAKE} --add-missing --copy || func_exit 1
   ) || func_exit 1
-  if test -n "$inctests" && ! $single_configure; then
+  if $inctests && ! $single_configure; then
     # Create autogenerated files.
     (cd "$testdir/$testsbase" || func_exit 1
      # Do not use "${AUTORECONF} --force --install", because it may invoke
 <at>  <at>  -6098,7 +6101,7  <at>  <at> 
                                esac;
                              done`
   tests_distributed_built_sources=
-  if test -n "$inctests"; then
+  if $inctests; then
     # Likewise for built files in the $testsbase directory.
     tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" <
"$testdir/$testsbase/Makefile.am" \
                          | sed -n -e 's,^CLEANFILES[	 ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[	 ]*+=\([^#]*\).*$,\1,p'`

Thien-Thi Nguyen | 22 Jun 2012 11:35
Favicon

Re: gnulib-tool and --with-tests

() Bruno Haible <bruno <at> clisp.org>
() Thu, 21 Jun 2012 22:46:02 +0200

   gnulib-tool: --create-[mega]testdir, --[mega]test implies --with-tests.

Apparently, ‘--with-tests’ is implied (somehow) by ‘--update’ as well
(but that is incompatible (why?) with ‘--conditional-dependencies’):

 http://hydra.nixos.org/build/2724974/log/tail-reload

I suppose a workaround would be to specify ‘--without-tests’ in
the gnulib-tool invocation:

 http://git.savannah.gnu.org/cgit/rcs.git/tree/autogen.sh#n21

but that strikes me as inelegant.  Am i missing something?

Bruno Haible | 22 Jun 2012 17:56

Re: gnulib-tool and --with-tests

Thien-Thi Nguyen wrote:
>    gnulib-tool: --create-[mega]testdir, --[mega]test implies --with-tests.
> 
> Apparently, ‘--with-tests’ is implied (somehow) by ‘--update’ as well

In --update mode, the settings come from the gnulib-cache.m4 file,
in your case it's here:
  http://git.savannah.gnu.org/cgit/rcs.git/tree/m4/gnulib-cache.m4

> (but that is incompatible (why?) with ‘--conditional-dependencies’):

Yes, --with-tests and --conditional-dependencies are currently incompatible.
(because the logic is too complicated).

Your gnulib-cache.m4 lists both gl_TESTS_BASE and gl_CONDITIONAL_DEPENDENCIES;
this is where the conflict comes from. Remove one of them.

>  http://git.savannah.gnu.org/cgit/rcs.git/tree/autogen.sh#n21

According to the 'gnulib-tool --help' message, you are not supposed to
use --conditional-dependencies with --update. The intended usage is that
you invoke
  gnulib-tool --conditional-dependencies --import
*once*, this will store the option in the gnulib-cache.m4 file. Then
further uses of
  gnulib-tool --update
will take the option from the gnulib-cache.m4 file.

Likewise for --without-tests. Pass it once, then it will be stored.

Bruno


Gmane