[PATCH v2 2/5] test: Made T010-help-test and T020-compact tests more portable.

Charles Celerier cceleri at cs.stanford.edu
Sat May 10 08:53:44 PDT 2014


The tests T010-help-test and T020-compact use the files have-man and
have-compact, respectively, as indicators of how notmuch is configured.
These were symbolic links to true and false for use in bash tests.
Unfortunately, the paths to true and false may not be the same on all
platforms (e.g. on Mac OS X they are in /usr/bin), so hard-coding
symbolic links to /bin/true and /bin/false is not portable. This patch
writes a 1 to have-man and have-compact to indicate true, and a 0 to
indicate false, instead. The tests now read the contents of the file to
determine the truth value instead of following the symbolic link.

Signed-off-by: Charles Celerier <cceleri at cs.stanford.edu>
---
 test/Makefile.local    | 8 ++++----
 test/T010-help-test.sh | 2 +-
 test/T020-compact.sh   | 2 +-
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/test/Makefile.local b/test/Makefile.local
index d622eaf..8fd333c 100644
--- a/test/Makefile.local
+++ b/test/Makefile.local
@@ -37,16 +37,16 @@ $(dir)/parse-time: $(dir)/parse-time.o parse-time-string/parse-time-string.o
 
 $(dir)/have-compact: Makefile.config
 ifeq ($(HAVE_XAPIAN_COMPACT),1)
-	ln -sf /bin/true $@
+	echo 1 > $@
 else
-	ln -sf /bin/false $@
+	echo 0 > $@
 endif
 
 $(dir)/have-man: Makefile.config
 ifeq ($(HAVE_SPHINX)$(HAVE_RST2MAN),00)
-	ln -sf /bin/false $@
+	echo 0 > $@
 else
-	ln -sf /bin/true $@
+	echo 1 > $@
 endif
 
 .PHONY: test check
diff --git a/test/T010-help-test.sh b/test/T010-help-test.sh
index 77410bc..02162ca 100755
--- a/test/T010-help-test.sh
+++ b/test/T010-help-test.sh
@@ -7,7 +7,7 @@ test_expect_success 'notmuch --help' 'notmuch --help'
 test_expect_success 'notmuch help' 'notmuch help'
 test_expect_success 'notmuch --version' 'notmuch --version'
 
-if ${TEST_DIRECTORY}/have-man; then
+if grep -q 1 ${TEST_DIRECTORY}/have-man ; then
     test_expect_success 'notmuch --help tag' 'notmuch --help tag'
     test_expect_success 'notmuch help tag' 'notmuch help tag'
 else
diff --git a/test/T020-compact.sh b/test/T020-compact.sh
index 77bb963..0139584 100755
--- a/test/T020-compact.sh
+++ b/test/T020-compact.sh
@@ -10,7 +10,7 @@ notmuch tag +tag1 \*
 notmuch tag +tag2 subject:Two
 notmuch tag -tag1 +tag3 subject:Three
 
-if ! ${TEST_DIRECTORY}/have-compact; then
+if grep -q 0 ${TEST_DIRECTORY}/have-compact; then
     test_begin_subtest "Compact unsupported: error message"
     output=$(notmuch compact --quiet 2>&1)
     test_expect_equal "$output" "notmuch was compiled against a xapian version lacking compaction support.
-- 
1.8.5.2 (Apple Git-48)



More information about the notmuch mailing list