[PATCH v2 1/2] tests: move code to run completion tests under bash into a helper library

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: SZEDER Gábor <szeder@xxxxxxxxxx>
---

On Mon, Apr 16, 2012 at 11:01:24AM -0500, Jonathan Nieder wrote:
> SZEDER Gábor wrote:
> 
> > I thought about that briefly but decided against it to avoid
> > duplicating the bash-specific checks at the beginning, but I don't
> > care that much either way.
> 
> Maybe a t/lib-completion.sh would take care of that.

Here you go.  I put only the conditionals to run the test script under
Bash and the sourcing of test-lib.sh into t/lib-completion.sh, because
that's the common part that is required by the prompt tests, too.  So in
the end I'm not sure that t/lib-completion.sh is the right name for this
file.

This patch could probably be squashed into the first commit of
fc/completion-tests, i.e. 5c293a6b (tests: add initial bash completion
tests, 2012-04-12).

 t/lib-completion.sh   |   17 +++++++++++++++++
 t/t9902-completion.sh |   14 +-------------
 2 files changed, 18 insertions(+), 13 deletions(-)
 create mode 100644 t/lib-completion.sh

diff --git a/t/lib-completion.sh b/t/lib-completion.sh
new file mode 100644
index 00000000..3d85feb2
--- /dev/null
+++ b/t/lib-completion.sh
@@ -0,0 +1,17 @@
+#!/bin/sh
+#
+# Ensures that tests of the completion script are run under Bash.
+
+if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then
+	# we are in full-on bash mode
+	true
+elif type bash >/dev/null 2>&1; then
+	# execute in full-on bash mode
+	unset POSIXLY_CORRECT
+	exec bash "$0" "$@"
+else
+	echo '1..0 #SKIP skipping bash completion tests; bash not available'
+	exit 0
+fi
+
+. ./test-lib.sh
diff --git a/t/t9902-completion.sh b/t/t9902-completion.sh
index a6eaa15c..90b2f22e 100755
--- a/t/t9902-completion.sh
+++ b/t/t9902-completion.sh
@@ -3,21 +3,9 @@
 # Copyright (c) 2012 Felipe Contreras
 #
 
-if test -n "$BASH" && test -z "$POSIXLY_CORRECT"; then
-	# we are in full-on bash mode
-	true
-elif type bash >/dev/null 2>&1; then
-	# execute in full-on bash mode
-	unset POSIXLY_CORRECT
-	exec bash "$0" "$@"
-else
-	echo '1..0 #SKIP skipping bash completion tests; bash not available'
-	exit 0
-fi
-
 test_description='test bash completion'
 
-. ./test-lib.sh
+. ./lib-completion.sh
 
 complete ()
 {
-- 
1.7.10.216.gb52c0

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]