From mboxrd@z Thu Jan 1 00:00:00 1970 From: =?UTF-8?q?=C3=86var=20Arnfj=C3=B6r=C3=B0=20Bjarmason?= Subject: [PATCH] test-lib: make test_expect_code a test command Date: Fri, 1 Oct 2010 17:16:31 +0000 Message-ID: <1285953391-29840-1-git-send-email-avarab@gmail.com> References: <7vd3rtholo.fsf@alter.siamese.dyndns.org> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Junio C Hamano , Elijah Newren , Jonathan Nieder , =?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:16:51 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 1P1jDz-0007Sb-Ih for gcvg-git-2@lo.gmane.org; Fri, 01 Oct 2010 19:16:48 +0200 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751670Ab0JARQl convert rfc822-to-quoted-printable (ORCPT ); Fri, 1 Oct 2010 13:16:41 -0400 Received: from mail-ww0-f44.google.com ([74.125.82.44]:59121 "EHLO mail-ww0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751501Ab0JARQk (ORCPT ); Fri, 1 Oct 2010 13:16:40 -0400 Received: by wwj40 with SMTP id 40so1621439wwj.1 for ; Fri, 01 Oct 2010 10:16:39 -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=rTQ3bbE6cPAk+OLlcyIA4lCNdszytmz6JjZLC13NXqo=; b=TRoLurE9pVYHISdzidPkz5KR6WyAZsPnObocAJrjff/fvOODseo/3NYhDs5HgIKxC/ 9ulIytGI2NVRM86eQEIOOCk1I9Elog7gzRoYO6m6fayMjbNtOSxx663ZrQ1W9I5PCs4C cwsM9iglvueEK8fpyZgUZBVsbaiKir0VNu3fA= 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=j8YLLFSSHoW9M3UVyBN+IzuUVSLLzY4sfn4u646oYspPWzPLFOBksmH6BRG/92EZFB /b1wx+SLSci1Pp36dKFKIRoJHSOkW7NenRg0rGI34JL2xWdP9fZaHPr7iXzAVh298dlC n81IkL4AsOG7ygjUQu2nefdpMDPg2hBhpHmOU= Received: by 10.216.153.140 with SMTP id f12mr2345960wek.111.1285953398974; Fri, 01 Oct 2010 10:16:38 -0700 (PDT) Received: from v.nix.is (v.nix.is [109.74.193.250]) by mx.google.com with ESMTPS id u32sm935153weq.11.2010.10.01.10.16.37 (version=SSLv3 cipher=RC4-MD5); Fri, 01 Oct 2010 10:16:37 -0700 (PDT) X-Mailer: git-send-email 1.7.3.159.g610493 In-Reply-To: <7vd3rtholo.fsf@alter.siamese.dyndns.org> 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 no the TODO test I added in v1.7.3-rc0~2^2~3. Signed-off-by: =C3=86var Arnfj=C3=B6r=C3=B0 Bjarmason --- On Fri, Oct 1, 2010 at 16:20, Junio C Hamano wrote: > =C3=86var Arnfj=C3=B6r=C3=B0 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 you= r >> check_exit_status does), and not at the top-level. > > I like it. =C2=A0It should have been done the way you suggest from th= e > beginning. =C2=A0It is unfortunate that we didn't think of wrappers l= ike > test_must_fail and friends when we originally did test_expect_code, b= ut 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. =20 - - test_expect_code []