- Add a helper script that runs a completion and checks that it
reaches the expected outcome
- Add an example of test (in our usual test suite) using it
- Caveat: you probably need to chmod +x test/run-test-completion.in
This closes #41688.
---
Makefile.in | 6 +++++-
test/completion.test | 10 ++++++++++
test/run-test-completion.in | 42 ++++++++++++++++++++++++++++++++++++++++++
3 files changed, 57 insertions(+), 1 deletion(-)
Index: b/test/completion.test
===================================================================
--- /dev/null
+++ b/test/completion.test
@@ -0,0 +1,10 @@
+$ ../run-test-completion add quilt ad
+>~ PASS:.*
+
+$ ../run-test-completion "add annotate applied" quilt a
+>~ PASS:.*
+
+$ ../run-test-completion "" quilt toppp
+>~ PASS:.*
+
+
Index: b/test/run-test-completion.in
===================================================================
--- /dev/null
+++ b/test/run-test-completion.in
@@ -0,0 +1,42 @@
+#! @BASH@
+
+# Little test runner for the bash completion
+
+# Usage: run-test-completion "expected output" the command line to complete
+#
+# $ run-test-completion "add" quilt ad
+# PASS: quilt ad -> add
+# $ run-test-completion "add" quilt a
+# FAIL: quilt a -> add annotate applied != add
+# $ run-test-completion "" quilt toppp
+# PASS: quilt toppp ->
+
+
+# This script is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# See the COPYING and AUTHORS files for more details.
+
+
+set -e
+source ../../bash_completion
+
+expected_output=$1
+shift
+
+declare -a COMP_WORDS=()
+for arg in "$@" ; do
+ COMP_WORDS[${#COMP_WORDS[@]}]=$arg
+done
+COMP_CWORD=${#COMP_WORDS[@]}-1
+
+set +e # _quilt_completion fails when completing something with no existing
completion, such as "quilt topppp"
+_quilt_completion -o filenames quilt
+observed_output="${COMPREPLY[*]}"
+
+if [ "$expected_output" = "$observed_output" ] ; then
+ echo "PASS: $@ -> $expected_output"
+else
+ echo "FAIL: $@ -> $observed_output != $expected_output"
+fi
Index: b/Makefile.in
===================================================================
--- a/Makefile.in
+++ b/Makefile.in
@@ -79,6 +79,9 @@
SRC += $(QUILT_SRC:%=quilt/%)
DIRT += $(QUILT_IN:%=quilt/%)
+SRC += test/run-test-completion.in
+DIRT += test/run-test-completion
+
SCRIPTS_IN := patchfns inspect dependency-graph edmail \
remove-trailing-ws backup-files
@@ -148,7 +151,8 @@
scripts : $(BIN:%=bin/%) $(QUILT:%=quilt/%) \
$(SCRIPTS:%=quilt/scripts/%) \
- $(if $(PATCH_WRAPPER),bin/patch-wrapper)
+ $(if $(PATCH_WRAPPER),bin/patch-wrapper) \
+ test/run-test-completion
dist : clean $(PACKAGE)-$(VERSION).tar.gz
_______________________________________________
Quilt-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/quilt-dev