The following commit has been merged in the master branch:
commit d930a669733d0c14a8da3923c67becd92e2fa1c4
Author: Benjamin Drung <[email protected]>
Date: Tue Apr 17 22:02:16 2012 +0200
Introduce a test suite for the scripts based on shunit2.
diff --git a/debian/changelog b/debian/changelog
index 0083bab..8540af8 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,6 @@
devscripts (2.11.7) UNRELEASED; urgency=low
+ [ James McCoy ]
* bts: Generate a proper Cc field with "reassign … . done …". (Closes:
#668132)
* debchange: Remove EOLed releases Lenny and Maverick.
@@ -8,7 +9,10 @@ devscripts (2.11.7) UNRELEASED; urgency=low
* debcheckout: Allow specifying a branch for Vcs-Git fields. Thanks to
Bernhard R. Link for the patch. (Closes: #655085)
- -- James McCoy <[email protected]> Mon, 09 Apr 2012 19:27:24 -0400
+ [ Benjamin Drung ]
+ * Introduce a test suite for the scripts based on shunit2.
+
+ -- Benjamin Drung <[email protected]> Tue, 17 Apr 2012 22:01:16 +0200
devscripts (2.11.6) unstable; urgency=low
diff --git a/debian/control b/debian/control
index 5f89b94..dfc9c7e 100644
--- a/debian/control
+++ b/debian/control
@@ -31,6 +31,7 @@ Build-Depends: debhelper (>= 8),
python-magic,
python-setuptools,
python-unittest2,
+ shunit2 (>= 2.1.6),
xsltproc
X-Python-Version: >= 2.6
Vcs-Browser: http://anonscm.debian.org/gitweb/?p=devscripts/devscripts.git
diff --git a/test/Makefile b/test/Makefile
index 239bba8..41077a0 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -1,3 +1,4 @@
test:
+ ./test-checkbashisms
.PHONY: test
diff --git a/test/bashisms/source b/test/bashisms/source
new file mode 100644
index 0000000..b6bd669
--- /dev/null
+++ b/test/bashisms/source
@@ -0,0 +1,2 @@
+#!/bin/sh
+source foo.sh
diff --git a/test/test-checkbashisms b/test/test-checkbashisms
new file mode 100755
index 0000000..5a9dbe1
--- /dev/null
+++ b/test/test-checkbashisms
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# Copyright (C) 2012, Benjamin Drung <[email protected]>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted, provided that the above
+# copyright notice and this permission notice appear in all copies.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+
+COMMAND="../scripts/checkbashisms.pl"
+WORKDIR="$(readlink -f "${0%/*}")"
+
+runCommand() {
+ local param="$1"
+ local exp_stdout="$2"
+ local exp_stderr="$3"
+ local exp_retval=$4
+ local stdoutF="${SHUNIT_TMPDIR}/stdout"
+ local stderrF="${SHUNIT_TMPDIR}/stderr"
+ eval "${COMMAND} $param" > ${stdoutF} 2> ${stderrF}
+ retval=$?
+ assertEquals "standard output of ${COMMAND} $param\n" "$exp_stdout" "$(cat
${stdoutF})"
+ assertEquals "error output of ${COMMAND} $param\n" "$exp_stderr" "$(cat
${stderrF})"
+ assertEquals "return value of ${COMMAND} $param\n" $exp_retval $retval
+}
+
+found() {
+ cd "$WORKDIR"
+ runCommand "$1" "" "$2" 1
+}
+
+testSource() {
+ local result="possible bashism in bashisms/source line 2 (should be '.',
not 'source'):
+source foo.sh"
+ found "bashisms/source" "$result"
+}
+
+. shunit2
--
Git repository for devscripts
--
To unsubscribe, send mail to [email protected].