git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] t0020-crlf: check the right file
@ 2018-08-22 12:44 SZEDER Gábor
  2018-08-22 12:44 ` [PATCH 2/2] t4051-diff-function-context: read " SZEDER Gábor
  2018-08-22 16:11 ` [PATCH 1/2] t0020-crlf: check " Junio C Hamano
  0 siblings, 2 replies; 4+ messages in thread
From: SZEDER Gábor @ 2018-08-22 12:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

In the test 'checkout with autocrlf=input' in 't0020-crlf.sh', one of
the 'has_cr' checks looks at the non-existing file 'two' instead of
'dir/two'.  The test still succeeds, without actually checking what it
was supposed to, because this check is expected to fail anyway.

As a minimal fix, fix the name of the file to be checked.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t0020-crlf.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 5f056982a5..854da0ae16 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -160,7 +160,7 @@ test_expect_success 'checkout with autocrlf=input' '
 	git config core.autocrlf input &&
 	git read-tree --reset -u HEAD &&
 	test_must_fail has_cr one &&
-	test_must_fail has_cr two &&
+	test_must_fail has_cr dir/two &&
 	git update-index -- one dir/two &&
 	test "$one" = $(git hash-object --stdin <one) &&
 	test "$two" = $(git hash-object --stdin <dir/two) &&
-- 
2.19.0.rc0.136.gd2dd172e64


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] t4051-diff-function-context: read the right file
  2018-08-22 12:44 [PATCH 1/2] t0020-crlf: check the right file SZEDER Gábor
@ 2018-08-22 12:44 ` SZEDER Gábor
  2018-08-22 16:11 ` [PATCH 1/2] t0020-crlf: check " Junio C Hamano
  1 sibling, 0 replies; 4+ messages in thread
From: SZEDER Gábor @ 2018-08-22 12:44 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, SZEDER Gábor

The test ' context does not include preceding empty lines' in the
block of tests 'change with long common tail and no context' in
't4051-diff-function-context.sh' tries to read the file
'long_common_tail.diff.diff', but that file doesn't exist as its name
contains one more '.diff' suffixes than necessary.

Despite this error the test still succeeded without checking what it's
supposed to, because this erroneous read is done on the line:

  test "$(first_context_line <long_common_tail.diff.diff)" != " "

which means that:

  - the command substitution hides the error, so it won't fail the
    test, and

  - the result of the command substitution is the empty string, which
    is, of course, not equal to a single space character, so the
    condition is fulfilled, and the test succeeds.

As a minimal fix, fix the name of the file to be read.

In the future we might want to reorganize this test script (1) to use
'test_cmp' instead of 'test's and command substitutions to catch
failing commands and to provide helpful error messages, and (2) to
specify what the expected result actually _is_ instead of what it
isn't.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t4051-diff-function-context.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh
index 2d76a971c4..4838a1df8b 100755
--- a/t/t4051-diff-function-context.sh
+++ b/t/t4051-diff-function-context.sh
@@ -174,7 +174,7 @@ test_expect_success ' context does not include other functions' '
 '
 
 test_expect_success ' context does not include preceding empty lines' '
-	test "$(first_context_line <long_common_tail.diff.diff)" != " "
+	test "$(first_context_line <long_common_tail.diff)" != " "
 '
 
 check_diff changed_hello_appended 'changed function plus appended function'
-- 
2.19.0.rc0.136.gd2dd172e64


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] t0020-crlf: check the right file
  2018-08-22 12:44 [PATCH 1/2] t0020-crlf: check the right file SZEDER Gábor
  2018-08-22 12:44 ` [PATCH 2/2] t4051-diff-function-context: read " SZEDER Gábor
@ 2018-08-22 16:11 ` Junio C Hamano
  2018-08-22 16:30   ` Jeff King
  1 sibling, 1 reply; 4+ messages in thread
From: Junio C Hamano @ 2018-08-22 16:11 UTC (permalink / raw)
  To: SZEDER Gábor; +Cc: git

SZEDER Gábor <szeder.dev@gmail.com> writes:

> In the test 'checkout with autocrlf=input' in 't0020-crlf.sh', one of
> the 'has_cr' checks looks at the non-existing file 'two' instead of
> 'dir/two'.  The test still succeeds, without actually checking what it
> was supposed to, because this check is expected to fail anyway.
>
> As a minimal fix, fix the name of the file to be checked.
>
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---

This originates from fd777141 ("t0020: fix ignored exit code inside
loops", 2015-03-25) where a loop

    for f in one dir/two
    do
            do things on "$f" || break
    done

was unrolled to correctly break out of the &&-chain.  The filenames
on the update-index line correctly copied one and dir/two, but the
has_cr line somehow lost dir/ prefix.

Thanks.  Will queue.

>  t/t0020-crlf.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
> index 5f056982a5..854da0ae16 100755
> --- a/t/t0020-crlf.sh
> +++ b/t/t0020-crlf.sh
> @@ -160,7 +160,7 @@ test_expect_success 'checkout with autocrlf=input' '
>  	git config core.autocrlf input &&
>  	git read-tree --reset -u HEAD &&
>  	test_must_fail has_cr one &&
> -	test_must_fail has_cr two &&
> +	test_must_fail has_cr dir/two &&
>  	git update-index -- one dir/two &&
>  	test "$one" = $(git hash-object --stdin <one) &&
>  	test "$two" = $(git hash-object --stdin <dir/two) &&

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] t0020-crlf: check the right file
  2018-08-22 16:11 ` [PATCH 1/2] t0020-crlf: check " Junio C Hamano
@ 2018-08-22 16:30   ` Jeff King
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff King @ 2018-08-22 16:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: SZEDER Gábor, git

On Wed, Aug 22, 2018 at 09:11:08AM -0700, Junio C Hamano wrote:

> This originates from fd777141 ("t0020: fix ignored exit code inside
> loops", 2015-03-25) where a loop
> 
>     for f in one dir/two
>     do
>             do things on "$f" || break
>     done
> 
> was unrolled to correctly break out of the &&-chain.  The filenames
> on the update-index line correctly copied one and dir/two, but the
> has_cr line somehow lost dir/ prefix.
> 
> Thanks.  Will queue.

Whoops, my error. Thanks for catching it.

> > diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
> > index 5f056982a5..854da0ae16 100755
> > --- a/t/t0020-crlf.sh
> > +++ b/t/t0020-crlf.sh
> > @@ -160,7 +160,7 @@ test_expect_success 'checkout with autocrlf=input' '
> >  	git config core.autocrlf input &&
> >  	git read-tree --reset -u HEAD &&
> >  	test_must_fail has_cr one &&
> > -	test_must_fail has_cr two &&
> > +	test_must_fail has_cr dir/two &&

I think I'm also responsible for these mis-uses of test_must_fail, which
probably ought to be "!".

-Peff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-08-22 16:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-22 12:44 [PATCH 1/2] t0020-crlf: check the right file SZEDER Gábor
2018-08-22 12:44 ` [PATCH 2/2] t4051-diff-function-context: read " SZEDER Gábor
2018-08-22 16:11 ` [PATCH 1/2] t0020-crlf: check " Junio C Hamano
2018-08-22 16:30   ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).