From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH v2] test-lib: make test_expect_code a test command Date: Fri, 1 Oct 2010 17:42:20 +0000 Message-ID: <1285954940-4247-1-git-send-email-avarab@gmail.com> References: <1285953391-29840-1-git-send-email-avarab@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Junio C Hamano , Elijah Newren , Jonathan Nieder , Sverre Rabbelier , =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= To: git@vger.kernel.org X-From: git-owner@vger.kernel.org Fri Oct 01 19:42:36 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 1P1jcx-0006om-S7 for gcvg-git-2@lo.gmane.org; Fri, 01 Oct 2010 19:42:36 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753509Ab0JARmb convert rfc822-to-quoted-printable (ORCPT ); Fri, 1 Oct 2010 13:42:31 -0400 Received: from mail-wy0-f174.google.com ([74.125.82.174]:54666 "EHLO mail-wy0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752263Ab0JARma (ORCPT ); Fri, 1 Oct 2010 13:42:30 -0400 Received: by wyb28 with SMTP id 28so3169352wyb.19 for ; Fri, 01 Oct 2010 10:42:28 -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=EmTRH2yz0KczTbM6YHcGjwIX51bq4rocYlfe4rrfWek=; b=dp6eCIAsarMwvMOwo1gO/ysI4zmXkFzyR8OJJUHInSJH9ajuvYU7Whaa8yOpb1+Isk SD7/GnwuDKAOECOBCeUimpkdzBSjB7cDWJUCLehjDArfpTTLgyVGWjU6LCjo3YYkpb8K Uvmm6hopRjGUgpzcNfEB3rHMs2EfYgVE81lJI= 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=EcbqpVgWNID+xPnGE6i8p6lDMgHZfGdYoZWt6rzDeBk9dvZfNeHFjpIf8FEWzGbjhv 3U7goF2IEYT9PtCPllcj7Jju0EqVupPKZYU+6ksC6rDSPMrLqkTkhLLY9Tqv4gbrzbjv YP6DJYtdTKkymbeh4NZ4Pfn/HB12FQ4DBuyM4= Received: by 10.216.17.135 with SMTP id j7mr4730175wej.97.1285954948646; Fri, 01 Oct 2010 10:42:28 -0700 (PDT) Received: from v.nix.is (v.nix.is [109.74.193.250]) by mx.google.com with ESMTPS id n17sm955997weq.6.2010.10.01.10.42.26 (version=SSLv3 cipher=RC4-MD5); Fri, 01 Oct 2010 10:42:27 -0700 (PDT) X-Mailer: git-send-email 1.7.3.159.g610493 In-Reply-To: <1285953391-29840-1-git-send-email-avarab@gmail.com> Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Archived-At: 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 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 --- =46ixed s/no the/to the/ typo in the commit message spotted by Sverre Rabbelier. 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. =20 - - test_expect_code []