[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] init.sh: new module, and add minimal tests of its compare fu
From: |
Jim Meyering |
Subject: |
Re: [PATCH] init.sh: new module, and add minimal tests of its compare function |
Date: |
Fri, 23 Dec 2011 12:18:55 +0100 |
Bruno Haible wrote:
>> * modules/init.sh: New file.
>
> The module name 'init.sh' is not self-explanatory. How about one of these:
> test-framework
> test-frame
> test-framework-sh
> The latter name is because it is not impossible that someday we get also
> a test framework as a C program, like glibc has one.
Thank you for the suggestion.
I've taken the third one, in spite of its length, and split the
module creation and test-addition into separate commits.
>> as a next step, I'll
>> convert all of the Files: tests/init.sh references to module dependencies.
>
> When doing this, it will be good to check the results of
>
> $ ./gnulib-tool --create-testdir --with-tests $some_modules
>
> as well as
>
> $ ./gnulib-tool --create-testdir --with-tests --single-configure
> $some_modules
Of course, I would have tested, but would not have known
to use --single-configure. Thanks for the specific recommendation.
The following passed both with and without --single-configure:
./gnulib-tool --create-testdir --with-tests --test --single-configure \
atexit closein exclude getcwd perror pread pwrite test-framework-sh \
vc-list-files verify xalloc-die xstrtoimax xstrtol xstrtoll \
xstrtoumax yesno
In case anyone feels like looking in the next couple of hours,
here is the new series of three change-sets:
>From 94eb544e23cd3e9d6cc5f0bd834525b41c43ec2d Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 23 Dec 2011 10:53:10 +0100
Subject: [PATCH 1/3] test-framework-sh: new module
* modules/test-framework-sh: New file.
* MODULES.html.sh (Support for maintaining and releasing projects):
List it.
---
ChangeLog | 5 +++++
MODULES.html.sh | 1 +
modules/test-framework-sh | 19 +++++++++++++++++++
3 files changed, 25 insertions(+), 0 deletions(-)
create mode 100644 modules/test-framework-sh
diff --git a/ChangeLog b/ChangeLog
index 5545a2c..88ddad7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
2011-12-22 Jim Meyering <address@hidden>
+ test-framework-sh: new module
+ * modules/test-framework-sh: New file.
+ * MODULES.html.sh (Support for maintaining and releasing projects):
+ List it.
+
init.sh: do not emit simulated diff output to stderr
* tests/init.sh (compare_dev_null_): Print to stdout, not stderr.
diff --git a/MODULES.html.sh b/MODULES.html.sh
index bc8a1a6..2ddec49 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3525,6 +3525,7 @@ func_all_modules ()
func_module maintainer-makefile
func_module mktempd
func_module readme-release
+ func_module test-framework-sh
func_module update-copyright
func_module useless-if-before-free
func_module vc-list-files
diff --git a/modules/test-framework-sh b/modules/test-framework-sh
new file mode 100644
index 0000000..d1f3dd2
--- /dev/null
+++ b/modules/test-framework-sh
@@ -0,0 +1,19 @@
+Description:
+Bourne-shell-based testing framework
+
+Files:
+tests/init.sh
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+
+License:
+GPLed build tool
+
+Maintainer:
+Jim Meyering
--
1.7.8.1.367.g25ecc
>From b6ebe4ed8ebdd5c1d8b9229fc6bf631f09390242 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 23 Dec 2011 10:54:46 +0100
Subject: [PATCH 2/3] test-framework-sh: add minimal tests of init.sh's
compare function
* modules/test-framework-sh-tests: New file.
* tests/test-init.sh: New file.
---
ChangeLog | 4 ++
modules/test-framework-sh-tests | 10 ++++++
tests/test-init.sh | 68 +++++++++++++++++++++++++++++++++++++++
3 files changed, 82 insertions(+), 0 deletions(-)
create mode 100644 modules/test-framework-sh-tests
create mode 100755 tests/test-init.sh
diff --git a/ChangeLog b/ChangeLog
index 88ddad7..43336af 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
2011-12-22 Jim Meyering <address@hidden>
+ test-framework-sh: add minimal tests of init.sh's compare function
+ * modules/test-framework-sh-tests: New file.
+ * tests/test-init.sh: New file.
+
test-framework-sh: new module
* modules/test-framework-sh: New file.
* MODULES.html.sh (Support for maintaining and releasing projects):
diff --git a/modules/test-framework-sh-tests b/modules/test-framework-sh-tests
new file mode 100644
index 0000000..b004cf5
--- /dev/null
+++ b/modules/test-framework-sh-tests
@@ -0,0 +1,10 @@
+Files:
+tests/test-init.sh
+
+Depends-on:
+test-framework-sh
+
+configure.ac:
+
+Makefile.am:
+TESTS += test-init.sh
diff --git a/tests/test-init.sh b/tests/test-init.sh
new file mode 100755
index 0000000..32b523f
--- /dev/null
+++ b/tests/test-init.sh
@@ -0,0 +1,68 @@
+#!/bin/sh
+# Unit tests for init.sh
+# Copyright (C) 2011 Free Software Foundation, Inc.
+# This file is part of the GNUlib Library.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+: ${srcdir=.}
+. "$srcdir/init.sh"; path_prepend_ .
+
+fail=0
+
+test_compare()
+{
+ touch empty || fail=1
+ echo xyz > in || fail=1
+
+ compare /dev/null /dev/null >out 2>err || fail=1
+ test -s out && fail_ "out not empty: $(cat out)"
+ # "err" should be empty, too, but has "set -x" output when VERBOSE=yes
+ case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+ compare /dev/null empty >out 2>err || fail=1
+ test -s out && fail_ "out not empty: $(cat out)"
+ case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+ compare in in >out 2>err || fail=1
+ test -s out && fail_ "out not empty: $(cat out)"
+ case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+ compare /dev/null in >out 2>err && fail=1
+ cat <<\EOF > exp
+diff -u /dev/null in
+--- /dev/null 1970-01-01
++++ in 1970-01-01
++xyz
+EOF
+ compare exp out || fail=1
+ case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+
+ compare empty in >out 2>err && fail=1
+ # Remove the TAB-date suffix on each --- and +++ line,
+ # for both the expected and the actual output files.
+ cat <<\EOF > exp
+--- empty
++++ in
+@@ -0,0 +1 @@
++xyz
+EOF
+ sed 's/ .*//' out > k && mv k out
+ compare exp out || fail=1
+ case $- in *x*) ;; *) test -s err && fail_ "err not empty: $(cat err)";; esac
+}
+
+test_compare
+
+Exit $fail
--
1.7.8.1.367.g25ecc
>From ddc2851745729412966a1bc757665f819eab5dea Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Fri, 23 Dec 2011 12:14:15 +0100
Subject: [PATCH 3/3] maint: remove explicit Files: tests/init.sh; depend on
test-framework-sh
* modules/atexit-tests: Rather than listing tests/init.sh,
now that there's a module for it, simply depend on that new module.
* modules/closein-tests: Likewise.
* modules/exclude-tests: Likewise.
* modules/getcwd-tests: Likewise.
* modules/perror-tests: Likewise.
* modules/pread-tests: Likewise.
* modules/pwrite-tests: Likewise.
* modules/vc-list-files-tests: Likewise.
* modules/verify-tests: Likewise.
* modules/xalloc-die-tests: Likewise.
* modules/xstrtoimax-tests: Likewise.
* modules/xstrtol-tests: Likewise.
* modules/xstrtoll-tests: Likewise.
* modules/xstrtoumax-tests: Likewise.
* modules/yesno-tests: Likewise.
---
ChangeLog | 20 ++++++++++++++++++++
modules/atexit-tests | 2 +-
modules/closein-tests | 2 +-
modules/exclude-tests | 6 +++---
modules/getcwd-tests | 2 +-
modules/perror-tests | 2 +-
modules/pread-tests | 2 +-
modules/pwrite-tests | 2 +-
modules/vc-list-files-tests | 2 +-
modules/verify-tests | 2 +-
modules/xalloc-die-tests | 2 +-
modules/xstrtoimax-tests | 2 +-
modules/xstrtol-tests | 2 +-
modules/xstrtoll-tests | 2 +-
modules/xstrtoumax-tests | 2 +-
modules/yesno-tests | 4 ++--
16 files changed, 38 insertions(+), 18 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 43336af..f65801f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2011-12-23 Jim Meyering <address@hidden>
+
+ maint: remove explicit Files: tests/init.sh; depend on test-framework-sh
+ * modules/atexit-tests: Rather than listing tests/init.sh,
+ now that there's a module for it, simply depend on that new module.
+ * modules/closein-tests: Likewise.
+ * modules/exclude-tests: Likewise.
+ * modules/getcwd-tests: Likewise.
+ * modules/perror-tests: Likewise.
+ * modules/pread-tests: Likewise.
+ * modules/pwrite-tests: Likewise.
+ * modules/vc-list-files-tests: Likewise.
+ * modules/verify-tests: Likewise.
+ * modules/xalloc-die-tests: Likewise.
+ * modules/xstrtoimax-tests: Likewise.
+ * modules/xstrtol-tests: Likewise.
+ * modules/xstrtoll-tests: Likewise.
+ * modules/xstrtoumax-tests: Likewise.
+ * modules/yesno-tests: Likewise.
+
2011-12-22 Jim Meyering <address@hidden>
test-framework-sh: add minimal tests of init.sh's compare function
diff --git a/modules/atexit-tests b/modules/atexit-tests
index 1d1f0d0..815fce0 100644
--- a/modules/atexit-tests
+++ b/modules/atexit-tests
@@ -1,10 +1,10 @@
Files:
-tests/init.sh
tests/signature.h
tests/test-atexit.sh
tests/test-atexit.c
Depends-on:
+test-framework-sh
unistd
configure.ac:
diff --git a/modules/closein-tests b/modules/closein-tests
index 8cbf593..1cc6609 100644
--- a/modules/closein-tests
+++ b/modules/closein-tests
@@ -1,11 +1,11 @@
Files:
-tests/init.sh
tests/test-closein.sh
tests/test-closein.c
Depends-on:
binary-io
ignore-value
+test-framework-sh
configure.ac:
diff --git a/modules/exclude-tests b/modules/exclude-tests
index 072a4e6..9900fb3 100644
--- a/modules/exclude-tests
+++ b/modules/exclude-tests
@@ -1,5 +1,4 @@
Files:
-tests/init.sh
tests/test-exclude.c
tests/test-exclude1.sh
tests/test-exclude2.sh
@@ -11,9 +10,10 @@ tests/test-exclude7.sh
tests/test-exclude8.sh
Depends-on:
-progname
-error
argmatch
+error
+progname
+test-framework-sh
Makefile.am:
TESTS += \
diff --git a/modules/getcwd-tests b/modules/getcwd-tests
index 1cbf0fb..e5a7bd7 100644
--- a/modules/getcwd-tests
+++ b/modules/getcwd-tests
@@ -1,7 +1,6 @@
Files:
tests/test-getcwd.c
tests/test-getcwd.sh
-tests/init.sh
Depends-on:
errno
@@ -9,6 +8,7 @@ fcntl-h
getcwd-lgpl
pathmax
sys_stat
+test-framework-sh
configure.ac:
diff --git a/modules/perror-tests b/modules/perror-tests
index 5e41800..016c89d 100644
--- a/modules/perror-tests
+++ b/modules/perror-tests
@@ -1,5 +1,4 @@
Files:
-tests/init.sh
tests/macros.h
tests/signature.h
tests/test-perror.c
@@ -10,6 +9,7 @@ Depends-on:
dup2
ftruncate
strerror
+test-framework-sh
configure.ac:
diff --git a/modules/pread-tests b/modules/pread-tests
index 72e4613..eead17b 100644
--- a/modules/pread-tests
+++ b/modules/pread-tests
@@ -1,11 +1,11 @@
Files:
tests/test-pread.c
tests/test-pread.sh
-tests/init.sh
tests/signature.h
tests/macros.h
Depends-on:
+test-framework-sh
configure.ac:
diff --git a/modules/pwrite-tests b/modules/pwrite-tests
index 6249a8e..1dbdcc2 100644
--- a/modules/pwrite-tests
+++ b/modules/pwrite-tests
@@ -1,11 +1,11 @@
Files:
tests/test-pwrite.sh
tests/test-pwrite.c
-tests/init.sh
tests/signature.h
tests/macros.h
Depends-on:
+test-framework-sh
configure.ac:
diff --git a/modules/vc-list-files-tests b/modules/vc-list-files-tests
index 368a5bf..a66a45b 100644
--- a/modules/vc-list-files-tests
+++ b/modules/vc-list-files-tests
@@ -1,9 +1,9 @@
Files:
tests/test-vc-list-files-git.sh
tests/test-vc-list-files-cvs.sh
-tests/init.sh
Depends-on:
+test-framework-sh
configure.ac:
abs_aux_dir=`cd "$ac_aux_dir"; pwd`
diff --git a/modules/verify-tests b/modules/verify-tests
index 936ed56..939a1ce 100644
--- a/modules/verify-tests
+++ b/modules/verify-tests
@@ -1,9 +1,9 @@
Files:
tests/test-verify.c
tests/test-verify.sh
-tests/init.sh
Depends-on:
+test-framework-sh
configure.ac:
diff --git a/modules/xalloc-die-tests b/modules/xalloc-die-tests
index ca7acd2..e611f80 100644
--- a/modules/xalloc-die-tests
+++ b/modules/xalloc-die-tests
@@ -1,10 +1,10 @@
Files:
tests/test-xalloc-die.c
tests/test-xalloc-die.sh
-tests/init.sh
Depends-on:
progname
+test-framework-sh
Makefile.am:
TESTS += test-xalloc-die.sh
diff --git a/modules/xstrtoimax-tests b/modules/xstrtoimax-tests
index ea8e1ba..52dd71e 100644
--- a/modules/xstrtoimax-tests
+++ b/modules/xstrtoimax-tests
@@ -1,9 +1,9 @@
Files:
-tests/init.sh
tests/test-xstrtoimax.c
tests/test-xstrtoimax.sh
Depends-on:
+test-framework-sh
configure.ac:
diff --git a/modules/xstrtol-tests b/modules/xstrtol-tests
index 1fa29ab..da11c19 100644
--- a/modules/xstrtol-tests
+++ b/modules/xstrtol-tests
@@ -1,11 +1,11 @@
Files:
-tests/init.sh
tests/test-xstrtol.c
tests/test-xstrtoul.c
tests/test-xstrtol.sh
Depends-on:
inttypes
+test-framework-sh
configure.ac:
diff --git a/modules/xstrtoll-tests b/modules/xstrtoll-tests
index bef462a..d4e24d9 100644
--- a/modules/xstrtoll-tests
+++ b/modules/xstrtoll-tests
@@ -1,5 +1,4 @@
Files:
-tests/init.sh
tests/test-xstrtol.c
tests/test-xstrtoll.c
tests/test-xstrtoull.c
@@ -7,6 +6,7 @@ tests/test-xstrtoll.sh
Depends-on:
inttypes
+test-framework-sh
configure.ac:
diff --git a/modules/xstrtoumax-tests b/modules/xstrtoumax-tests
index 5d49c4b..83c4d1b 100644
--- a/modules/xstrtoumax-tests
+++ b/modules/xstrtoumax-tests
@@ -1,9 +1,9 @@
Files:
-tests/init.sh
tests/test-xstrtoumax.c
tests/test-xstrtoumax.sh
Depends-on:
+test-framework-sh
configure.ac:
diff --git a/modules/yesno-tests b/modules/yesno-tests
index 3e1e0a2..4582cef 100644
--- a/modules/yesno-tests
+++ b/modules/yesno-tests
@@ -1,11 +1,11 @@
Files:
-tests/init.sh
tests/test-yesno.c
tests/test-yesno.sh
Depends-on:
-closein
binary-io
+closein
+test-framework-sh
configure.ac:
--
1.7.8.1.367.g25ecc