From: Ævar Arnfjörð Bjarmason Date: Fri, 01 Oct 2010 17:16:31 GMT Subject: [PATCH] test-lib: make test_expect_code a test command Message-ID: <1285953391-29840-1-git-send-email-avarab@gmail.com> In-Reply-To: <7vd3rtholo.fsf@alter.siamese.dyndns.org> Change test_expect_code to be a normal test command instead of a top-level command. As a top-level command it would fail in cases like: test_expect_code 1 'phoney' ' foo && bar && (exit 1) ' Here the test might incorrectly succeed if "foo" or "bar" happened to fail with exit status 1. Instead we now do: test_expect_success 'phoney' ' foo && bar && test_expect_code 1 "(exit 1)" ' Which will only succeed if "foo" and "bar" return status 0, and "(exit 1)" returns status 1. Some test code in t0000-basic.sh relied on the old semantics of test_expect_code to test the test_when_finished command. I've converted that code to use an external test similar no the TODO test I added in v1.7.3-rc0~2^2~3. Signed-off-by: Ævar Arnfjörð Bjarmason --- On Fri, Oct 1, 2010 at 16:20, Junio C Hamano wrote: > Ævar Arnfjörð Bjarmason writes: >> So IMO the best thing to do would be to re-appropriate >> "test_expect_code" so that it runs inside a test (i.e. does what your >> check_exit_status does), and not at the top-level. > > I like it.  It should have been done the way you suggest from the > beginning.  It is unfortunate that we didn't think of wrappers like > test_must_fail and friends when we originally did test_expect_code, but it > is never too late to correct that mistake. Here's a patch to implement that. It goes on top of master so Elijah Newren's patch presumably will have to be re-done on top of it. t/README | 16 +++++++------ t/t0000-basic.sh | 55 ++++++++++++++++++++++++++++++++++++++-------- t/t1504-ceiling-dirs.sh | 5 ++- t/t6020-merge-df.sh | 4 ++- t/test-lib.sh | 40 ++++++++++++++++++--------------- 5 files changed, 82 insertions(+), 38 deletions(-) diff --git a/t/README b/t/README index a1eb7c8..c216e8c 100644 --- a/t/README +++ b/t/README @@ -395,13 +395,6 @@ library for your script to use. Like test_expect_success this function can optionally use a three argument invocation with a prerequisite as the first argument. - - test_expect_code []