Hi David.

On Mon, 16 Jan 2012 16:47:32 +0000, David Edmondson <dme at dme.org> wrote:
> "test_expect_emacs_t" expects a single argument. If this is `t' then
> the test passes. Otherwise the argument provides the details of the
> test failure to be reported.

Isn't this function the same as something like "test_expect_equal $x t"?

IMO the function seems too complex for what it does (and basically that
is "compare $x with t").  Why do we need to implement it in such a way?

Also, the function has nothing to do with emacs (except for the fact
that 't' is commonly used in it).

I think a more useful approach would be to add a function which takes a
lisp expression, runs test_emacs and compares the result with "t" using
test_expect_equal or similar.  This way you do not need to make an
explicit test_emacs call and avoid code duplication when checking the
result.  test_emacs_expect_t should be a good name for it.  What do you
think?

Regards,
  Dmitry

> ---
> 
> For use in the following set of tests and later for other emacs related tests.
> 
>  test/test-lib.sh |   20 ++++++++++++++++++++
>  1 files changed, 20 insertions(+), 0 deletions(-)
> 
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index d1fbc05..0ffe9a6 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -503,6 +503,26 @@ test_expect_equal_file ()
>      fi
>  }
>  
> +# Pass test if the result is `t', else report the results.
> +test_expect_emacs_t ()
> +{
> +     exec 1>&6 2>&7          # Restore stdout and stderr
> +     inside_subtest=
> +     test "$#" = 1 ||
> +     error "bug in the test script: not 1 parameter to test_expect_emacs_t"
> +
> +     result="$1"
> +     if ! test_skip "$test_subtest_name"
> +     then
> +             if [ "${result}" == "t" ] ; then
> +                     test_ok_ "$test_subtest_name"
> +             else
> +                     testname=$this_test.$test_count
> +                     test_failure_ "$test_subtest_name" "$(eval printf 
> ${result})"
> +             fi
> +    fi
> +}
> +
>  NOTMUCH_NEW ()
>  {
>      notmuch new | grep -v -E -e '^Processed [0-9]*( total)? file|Found 
> [0-9]* total file'
> -- 
> 1.7.7.3
> 
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> http://notmuchmail.org/mailman/listinfo/notmuch

Reply via email to