diff options
author | SZEDER Gábor <szeder.dev@gmail.com> | 2018-08-22 15:44:37 +0300 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-08-22 19:14:24 +0300 |
commit | c8b35b95e1990df7d325e08cf35e59f8eb77cf48 (patch) | |
tree | 28d37dbf78a1f34216fd19f2a0229b9508530219 /t | |
parent | d3621de789ab57739f48b065751089d828b50240 (diff) |
t4051-diff-function-context: read the right file
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>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4051-diff-function-context.sh | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/t/t4051-diff-function-context.sh b/t/t4051-diff-function-context.sh index ca017255ba4..3df24f2ef28 100755 --- a/t/t4051-diff-function-context.sh +++ b/t/t4051-diff-function-context.sh @@ -154,7 +154,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)" != " " ' test_done |