[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH] init.sh: new module, and add minimal tests of its compare functi
From: |
Jim Meyering |
Subject: |
[PATCH] init.sh: new module, and add minimal tests of its compare function |
Date: |
Thu, 22 Dec 2011 19:12:48 +0100 |
Here's a proposed minimal start at tests for tests/init.sh.
To add a test module, I also had to add a primary module,
so we now finally have an "init.sh" module, and as a next step, I'll
convert all of the Files: tests/init.sh references to module dependencies.
>From 7d3d2d00059b7b616596f015b37e334c27212722 Mon Sep 17 00:00:00 2001
From: Jim Meyering <address@hidden>
Date: Thu, 22 Dec 2011 19:03:43 +0100
Subject: [PATCH] init.sh: new module, and add minimal tests of its compare
function
* modules/init.sh-tests: New file.
* tests/test-init.sh: New file.
* modules/init.sh: New file.
* MODULES.html.sh (Support for maintaining and releasing projects):
List it.
---
ChangeLog | 7 +++++
MODULES.html.sh | 1 +
modules/init.sh | 19 +++++++++++++
modules/init.sh-tests | 9 ++++++
tests/test-init.sh | 68 +++++++++++++++++++++++++++++++++++++++++++++++++
5 files changed, 104 insertions(+), 0 deletions(-)
create mode 100644 modules/init.sh
create mode 100644 modules/init.sh-tests
create mode 100755 tests/test-init.sh
diff --git a/ChangeLog b/ChangeLog
index bcedee3..03db5fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,12 @@
2011-12-22 Jim Meyering <address@hidden>
+ init.sh: add minimal tests of the compare function
+ * modules/init.sh-tests: New file.
+ * tests/test-init.sh: New file.
+ * modules/init.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..012d65f 100755
--- a/MODULES.html.sh
+++ b/MODULES.html.sh
@@ -3522,6 +3522,7 @@ func_all_modules ()
func_module gnu-web-doc-update
func_module gnumakefile
func_module gnupload
+ func_module init.sh
func_module maintainer-makefile
func_module mktempd
func_module readme-release
diff --git a/modules/init.sh b/modules/init.sh
new file mode 100644
index 0000000..c591cb2
--- /dev/null
+++ b/modules/init.sh
@@ -0,0 +1,19 @@
+Description:
+testing framework
+
+Files:
+tests/init.sh
+
+Depends-on:
+
+configure.ac:
+
+Makefile.am:
+
+Include:
+
+License:
+GPLed build tool
+
+Maintainer:
+Jim Meyering
diff --git a/modules/init.sh-tests b/modules/init.sh-tests
new file mode 100644
index 0000000..17dff9e
--- /dev/null
+++ b/modules/init.sh-tests
@@ -0,0 +1,9 @@
+Files:
+tests/test-init.sh
+
+Depends-on:
+
+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.285.g92f25
- [PATCH] init.sh: new module, and add minimal tests of its compare function,
Jim Meyering <=