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

Jani Nikula jani at nikula.org
Fri May 30 00:49:16 PDT 2014


On Sat, 10 May 2014, Charles Celerier <cceleri at cs.stanford.edu> wrote:
> 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.

Please see [1] and [2] for what I think a better alternative.

BR,
Jani.


[1] id:1401435785-2894-1-git-send-email-jani at nikula.org
[2] id:1401435785-2894-2-git-send-email-jani at nikula.org



>
> 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)
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list