t2018: be more discerning when checking for expected exit codes
commit40caa5366a84fba6e64ea32bf98d9c1aba0c537b
authorDenton Liu <liu.denton@gmail.com>
Sun, 26 Jan 2020 20:23:05 +0000 (26 15:23 -0500)
committerJunio C Hamano <gitster@pobox.com>
Mon, 27 Jan 2020 20:55:42 +0000 (27 12:55 -0800)
treefdc68bf75937b1730f83df527f364d9aa4972171
parent5020f6806ac910d52f781ac76719c1cf66715632
t2018: be more discerning when checking for expected exit codes

Functions test_dirty_unmergeable() and test_dirty_mergeable()
expect git-diff to exit with the specific code 1. However, rather
than checking for that value explicitly, they instead negate the
exit code. Unfortunately, this negation makes it impossible to
distinguish the expected code from some other unexpected non-zero
code, for instance, from a segmentation fault. Therefore, be more
discerning by checking the exit code explicitly using
test_expect_code().

Furthermore, some callers of those functions want to negate the
result again, and do so with test_must_fail(). However,
test_must_fail() should only be used with git commands. Address
this by introducing a couple new tiny helper functions which test
the exact condition expected (without the unnecessarily confusing
double-negation).

Helped-by: Eric Sunshine <sunshine@sunshineco.com>
Signed-off-by: Denton Liu <liu.denton@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t2018-checkout-branch.sh