From mboxrd@z Thu Jan 1 00:00:00 1970 From: Elijah Newren Subject: [PATCHv6 01/16] test-lib: make test_expect_code a test command Date: Sun, 3 Oct 2010 13:59:59 -0600 Message-ID: <1286136014-7728-2-git-send-email-newren@gmail.com> References: <1286136014-7728-1-git-send-email-newren@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: gitster@pobox.com, avarab@gmail.com, jrnieder@gmail.com, Elijah Newren To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Sun Oct 03 21:58:56 2010 Return-path: Envelope-to: gcvg-git-2@lo.gmane.org Received: from vger.kernel.org ([209.132.180.67]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1P2Uhy-0002r3-T6 for gcvg-git-2@lo.gmane.org; Sun, 03 Oct 2010 21:58:55 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754671Ab0JCT6q convert rfc822-to-quoted-printable (ORCPT ); Sun, 3 Oct 2010 15:58:46 -0400 Received: from mail-px0-f174.google.com ([209.85.212.174]:52092 "EHLO mail-px0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754454Ab0JCT6q (ORCPT ); Sun, 3 Oct 2010 15:58:46 -0400 Received: by pxi10 with SMTP id 10so1157426pxi.19 for ; Sun, 03 Oct 2010 12:58:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references:mime-version :content-type:content-transfer-encoding; bh=Qy8dFMg0FdM+D3DkAWKxPdfBzH15KcvvZ+fPpcaEWK8=; b=HJiCMDTRbTpnZhdd3bpYlV66SCKKFkX9UFakW24OdaqtfbjjLOutZPxRe2yJYeRgPe +N/K9R+ql00qSYyEoSJ7CZtpwWEQaktQm28pmgC2fDZkGQ8RqBuebT3UOUc7QJolGJ6I DD6vW0VXIp5d1uDWINZ18xeTJLTZq9N2CTzw0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :mime-version:content-type:content-transfer-encoding; b=tNrooMVS/vpTg+ecEHEdnxXlS321/9zPQX0KbMV86nxQaC7D8EShFedteFN0h//OFz QXv1twzZtrBDmT2QIuS+ctdpkOrA5VA2IU0rXMmZvKn1V9WDaMXTibplb94NcEcgpEIi BE3PIs/UaWYWn8gHTNSNB/VTTmG4uTX7mFeCQ= Received: by 10.114.39.7 with SMTP id m7mr10058832wam.201.1286135924774; Sun, 03 Oct 2010 12:58:44 -0700 (PDT) Received: from Miney.hsd1.nm.comcast.net. (c-76-113-57-218.hsd1.nm.comcast.net [76.113.57.218]) by mx.google.com with ESMTPS id d2sm7661138wam.14.2010.10.03.12.58.42 (version=SSLv3 cipher=RC4-MD5); Sun, 03 Oct 2010 12:58:43 -0700 (PDT) X-Mailer: git-send-email 1.7.3.1.66.gab790 In-Reply-To: <1286136014-7728-1-git-send-email-newren@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: =46rom: =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason 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. Note that test_expect_code has been made slightl= y noisier, as it reports the exit code it receives even upon success. 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 to the TODO test I added in v1.7.3-rc0~2^2~3. Signed-off-by: =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason Acked-by: Jonathan Nieder Signed-off-by: Elijah Newren --- 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..ee4c0cf 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. =20 - - test_expect_code []