[PATCH] test: swap order of arguments of test_expect_equal

Tomi Ollila tomi.ollila at iki.fi
Thu Apr 6 09:24:45 PDT 2017


On Thu, Apr 06 2017, David Bremner <david at tethera.net> wrote:

> For some reason (probably inherited from git), the order arguments for
> test_expect_equal was "$output $expected"; this again matters when
> generating diffs.
> ---

IMO these both of these should use expected - output argument order.

But more important than that is to get 
id:20170405003630.15104-1-david at tethera.net merged soon so confusion
of output ends and if someone(tm) is doing near-future test changes
risk of collisions can be avoided.

Tomi


>
> I'm less sure about this one so I didn't go through and update all of
> the tests.  The existing use of test_expect_equal is mostly "$output"
> "$expected", which is natural enough, except that it's the opposite of
> the convention for test_expect_equal_file that I thought was obvious
> (I guess the latter motivated by the arguments to diff).
>
>  test/T000-basic.sh                         | 4 ++--
>  test/test-lib.sh                           | 5 +++--
>  test/test.expected-output/test-verbose-no  | 4 ++--
>  test/test.expected-output/test-verbose-yes | 4 ++--
>  4 files changed, 9 insertions(+), 8 deletions(-)
>
> diff --git a/test/T000-basic.sh b/test/T000-basic.sh
> index 36a7ca4c..0d6a2081 100755
> --- a/test/T000-basic.sh
> +++ b/test/T000-basic.sh
> @@ -52,7 +52,7 @@ suppress_diff_date() {
>  test_begin_subtest "Ensure that test output is suppressed unless the test fails"
>  output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= ./test-verbose 2>&1 | suppress_diff_date)
>  expected=$(cat $EXPECTED/test-verbose-no | suppress_diff_date)
> -test_expect_equal "$output" "$expected"
> +test_expect_equal "$expected" "$output"
>  
>  test_begin_subtest "Ensure that -v does not suppress test output"
>  output=$(cd $TEST_DIRECTORY; NOTMUCH_TEST_QUIET= ./test-verbose -v 2>&1 | suppress_diff_date)
> @@ -60,7 +60,7 @@ expected=$(cat $EXPECTED/test-verbose-yes | suppress_diff_date)
>  # Do not include the results of test-verbose in totals
>  rm $TEST_DIRECTORY/test-results/test-verbose
>  rm -r $TEST_DIRECTORY/tmp.test-verbose
> -test_expect_equal "$output" "$expected"
> +test_expect_equal "$expected" "$output"
>  
>  
>  ################################################################
> diff --git a/test/test-lib.sh b/test/test-lib.sh
> index 988b00af..374f6da5 100644
> --- a/test/test-lib.sh
> +++ b/test/test-lib.sh
> @@ -566,8 +566,9 @@ test_expect_equal ()
>  	test "$#" = 2 ||
>  	error "bug in the test script: not 2 parameters to test_expect_equal"
>  
> -	output="$1"
> -	expected="$2"
> +	expected="$1"
> +	output="$2"
> +
>  	if ! test_skip "$test_subtest_name"
>  	then
>  		if [ "$output" = "$expected" ]; then
> diff --git a/test/test.expected-output/test-verbose-no b/test/test.expected-output/test-verbose-no
> index 1a2ff619..07004182 100644
> --- a/test/test.expected-output/test-verbose-no
> +++ b/test/test.expected-output/test-verbose-no
> @@ -14,8 +14,8 @@ hello stderr
>  	--- test-verbose.4.expected	2010-11-14 21:41:12.738189710 +0000
>  	+++ test-verbose.4.output	2010-11-14 21:41:12.738189710 +0000
>  	@@ -1 +1 @@
> -	-b
> -	+a
> +	-a
> +	+b
>  hello stdout
>  hello stderr
>  
> diff --git a/test/test.expected-output/test-verbose-yes b/test/test.expected-output/test-verbose-yes
> index d25466e9..639b7fa7 100644
> --- a/test/test.expected-output/test-verbose-yes
> +++ b/test/test.expected-output/test-verbose-yes
> @@ -20,6 +20,6 @@ hello stderr
>  	--- test-verbose.4.expected	2010-11-14 21:41:06.650023289 +0000
>  	+++ test-verbose.4.output	2010-11-14 21:41:06.650023289 +0000
>  	@@ -1 +1 @@
> -	-b
> -	+a
> +	-a
> +	+b
>  
> -- 
> 2.11.0
>
> _______________________________________________
> notmuch mailing list
> notmuch at notmuchmail.org
> https://notmuchmail.org/mailman/listinfo/notmuch


More information about the notmuch mailing list