From patchwork Thu Oct 14 00:47:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12557589 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB33EC433EF for ; Thu, 14 Oct 2021 00:47:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A9812610E5 for ; Thu, 14 Oct 2021 00:47:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbhJNAtj (ORCPT ); Wed, 13 Oct 2021 20:49:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbhJNAth (ORCPT ); Wed, 13 Oct 2021 20:49:37 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D9BEC061746 for ; Wed, 13 Oct 2021 17:47:33 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id v17so13983071wrv.9 for ; Wed, 13 Oct 2021 17:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EPjZgzaHthQk42Wvcs+sm3GH3F6OuRygWQl9+LdOwUo=; b=E5d7vPDRW0DzRdRGNLos8/HWaDhqrB+lrS8bSODRBtBAtaWwrNwlUh1Ln+S1EFlStR 75q5zMnPF+Wmkdur4E+I/m6Yv9nHiv4KYS9uoao71MEVcgkme1Q4Mns2WOIeRNfZqU4M LD1xvVySTRudlkQgPIHT4qYOLRv/gX9oSCBPA377k9koVB+LUSfkoEYF/hrqnpzaMeyL vNWxTy0bDQ4GPwhrw/qQhA0eNr0wg4IJzSUp9EMr2pJ12DicvYywtNZ6NjiCeAxeWe3D CfmloHTF0w5i6b5kpa8tQ3fcCNGnoTpD9Llueyiaoiv+rIU++TMx04e5t/CFZhXcfTC9 iMOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EPjZgzaHthQk42Wvcs+sm3GH3F6OuRygWQl9+LdOwUo=; b=ENCr6jPR3iUoC03WolUgHbjIcIR53lPpO2JM8qfMsJ6Qwt61lVeQTUlDruYFDjhb3A ehTNKNVFATbwvCqtcMxNDod7BoX/0APUuqqLqLn+f2BIPFjp1pYtMB8LySJf7EnZ+jq7 ecRTuIAHxzP5hkKYxZ8/pvYa2irS8QzKSv6/IBff+W5HMuc6ITv62p5/K8XPNX/psYSz RKLvhybuSxdw7vO0smKfWZCxxDhYb97I91KRG2qoD31QiEd8aAy7NNfx1tHAZ4exBF9y d3+isK6yvCljw3Hg6hKlrq6UFNfO+M9Iqk2sStRX/BW8iCeD76l61ijSacMk9lqr79gr ThxQ== X-Gm-Message-State: AOAM530KvBRmbwhNYmWYy2+XMY2m816h5GtKg2VDdmVQH+gqQRIPq1DA 5XhUsKju+mH47NIRHnGDKEFeDZOz/2abig== X-Google-Smtp-Source: ABdhPJwr4MFS9yJ2p3B3IO4SItheu59eAz0IPDcBVhl5REf9oItpJYRbwJWjovshBiZ8xfShmD8f+Q== X-Received: by 2002:adf:a2d8:: with SMTP id t24mr2790554wra.91.1634172451539; Wed, 13 Oct 2021 17:47:31 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id w11sm736126wmc.44.2021.10.13.17.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 17:47:31 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 1/2] test-lib.sh: de-duplicate error() teardown code Date: Thu, 14 Oct 2021 02:47:28 +0200 Message-Id: X-Mailer: git-send-email 2.33.1.1346.g48288c3c089 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org De-duplicate the "finalize_junit_xml; GIT_EXIT_OK=t; exit 1" code shared between the "error()" and "--immediate on failure" code paths, in preparation for adding a third user in a subsequent commit. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index 8361b5c1c57..c610f09ddb1 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -589,13 +589,17 @@ USER_TERM="$TERM" TERM=dumb export TERM USER_TERM -error () { - say_color error "error: $*" +_error_exit () { finalize_junit_xml GIT_EXIT_OK=t exit 1 } +error () { + say_color error "error: $*" + _error_exit +} + BUG () { error >&7 "bug in the test script: $*" } @@ -720,7 +724,7 @@ test_failure_ () { say_color error "not ok $test_count - $1" shift printf '%s\n' "$*" | sed -e 's/^/# /' - test "$immediate" = "" || { finalize_junit_xml; GIT_EXIT_OK=t; exit 1; } + test "$immediate" = "" || _error_exit } test_known_broken_ok_ () { From patchwork Thu Oct 14 00:47:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= X-Patchwork-Id: 12557591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E663C433FE for ; Thu, 14 Oct 2021 00:47:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 110D361164 for ; Thu, 14 Oct 2021 00:47:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbhJNAtk (ORCPT ); Wed, 13 Oct 2021 20:49:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229660AbhJNAth (ORCPT ); Wed, 13 Oct 2021 20:49:37 -0400 Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D91EEC061749 for ; Wed, 13 Oct 2021 17:47:33 -0700 (PDT) Received: by mail-wr1-x42a.google.com with SMTP id o20so14093103wro.3 for ; Wed, 13 Oct 2021 17:47:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=73yukyy56fpF3h2Sl8c7BQCsdUm91DqixS5hPdhvuIk=; b=hOG1pjVCLyi8MUcxckyDGebBLMr5GHq9iRRrAVJ0Te3qb54P0MnZbZghT0l//Cx8IW vWG/HdOxwXTdRPHDpKpQ9NnD8WPMj6QQrFRC+jF6cm66h2+9b2Dj5DIXhMmj4ppMFgcR wyS39HK5I7Gvc/RSsGEXD2qvie2UO0oTWDZr2dvESPJ1yk7ghr/qBjw5MAcurhUDuP9M w6V6GjPQJye2267Q8HJCyfdCS525cI0c+ukBFrSxErSblEYk4U7evXEA/fZBbi7ELvAO i1tbp/TWid8rTH7m9rVZHUlWwcsBNvk4XGAJXkbRMKQqI4GPKuT9MNRyglTIrlqhnODf NQeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=73yukyy56fpF3h2Sl8c7BQCsdUm91DqixS5hPdhvuIk=; b=tCYARG+/jUKqjKCYoxlcrs/Rkyea0+uovCPQ2J4kepZxkNr3lCwg9OeB0Qk0iB4hVj kTJSOqnbNKMmXxNz/6cNf1UnwiKwtS28QAmVcwnto3z0TMwp6GLUEpi2ckg4WM9iuAZx vQuLj+CuzlLj7L2H4KQ24abSYy5n+b8ZcZ2xQnYmq5KqpXHv+s2C1HvZzrN1PkEHi6Cf FRD68aELZ4BTmcTtogYBcL6Iy+Rc9lx4cHjiXsVqxOA5oY7iFLWrPnhIuq/ZwDGsPWab Hb/vgR099E6Ro9iw6T78a0UD15lFT8X8Yg9JssMdbtNm6wRos8dIy146Bzbpf9kDUt/i vaZA== X-Gm-Message-State: AOAM532UbdFpbLAihUK+HRyQVnVCLs3g4ELpvm1PBXwkBK45wribA+F8 giZ/VvA3hp97wT4VdVx78ECsxgRZ0/TRbg== X-Google-Smtp-Source: ABdhPJwtvVLEZYO4M23KUDZpFaXz+5uCUp9jdh1KunLAcuXK6RrfUl+zDGrXdJ1PMIBG6jD384j9Qw== X-Received: by 2002:a5d:64ed:: with SMTP id g13mr2868679wri.193.1634172452220; Wed, 13 Oct 2021 17:47:32 -0700 (PDT) Received: from vm.nix.is (vm.nix.is. [2a01:4f8:120:2468::2]) by smtp.gmail.com with ESMTPSA id w11sm736126wmc.44.2021.10.13.17.47.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Oct 2021 17:47:31 -0700 (PDT) From: =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= To: git@vger.kernel.org Cc: Junio C Hamano , Jeff King , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBCamFybWFzb24=?= Subject: [PATCH 2/2] test-lib.sh: use "Bail out!" syntax on bad SANITIZE=leak use Date: Thu, 14 Oct 2021 02:47:29 +0200 Message-Id: X-Mailer: git-send-email 2.33.1.1346.g48288c3c089 In-Reply-To: References: MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Improve the "GIT_TEST_PASSING_SANITIZE_LEAK=true" test mode added in 956d2e4639b (tests: add a test mode for SANITIZE=leak, run it in CI, 2021-09-23) to use a TAP "Bail out!" message when exiting. This will cause the test run to exit immediately under a TAP consumer like "prove(1)". See 614fe015212 (test-lib: bail out when "-v" used under "prove", 2016-10-22) for the initial introduction of "Bail out!" to the --verbose being amended here. Before this compiling with "SANITIZE=" and running the tests with "prove(1)" would cause all the tests to be run to the end (output trimmed for fewer columns): $ GIT_TEST_PASSING_SANITIZE_LEAK=true make rm -f -r 'test-results' *** prove *** t0000-basic.sh ......... Dubious, test returned 1 (wstat 256, 0x100) No subtests run t0001-init.sh .......... Dubious, test returned 1 (wstat 256, 0x100) No subtests run [...output where we list every single t[0-9]*.sh file as failing snipped] Whereas now we'll fail early, like this ("->" line wrapping added): $ GIT_TEST_PASSING_SANITIZE_LEAK=true make [...] t0000-basic.sh ..................................... Bailout called. Further testing stopped: -> GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak FAILED--Further testing stopped: GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except -> when compiled with SANITIZE=leak make: *** [Makefile:53: prove] Error 1 This change also adds a red color to the "Bailout called" line, as we're now using "say_color error". That improves existing output in the case of e.g.: $ prove -j8 t[0-9]*.sh :: -v Bailout called. Further testing stopped: verbose mode forbidden under TAP harness; try --verbose-log FAILED--Further testing stopped: verbose mode forbidden under TAP harness; try --verbose-log We don't need to have a "Bail out! " prefix when we're not running under a TAP consumer (i.e. if test -n "$HARNESS_ACTIVE"), but let's not make the output conditional on that. Showing it under e.g.: $ GIT_TEST_PASSING_SANITIZE_LEAK=true ./t0095-bloom.sh Bail out! GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak Doesn't harm anything, and I don't think the (small) complexity of only adding this if we're under "$HARNESS_ACTIVE" is worth it. Signed-off-by: Ævar Arnfjörð Bjarmason --- t/test-lib.sh | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/t/test-lib.sh b/t/test-lib.sh index c610f09ddb1..617cda36f3a 100644 --- a/t/test-lib.sh +++ b/t/test-lib.sh @@ -604,6 +604,18 @@ BUG () { error >&7 "bug in the test script: $*" } +BAIL_OUT () { + test $# -ne 1 && BUG "1 param" + + # Do not change "Bail out! " string. It's part of TAP syntax: + # https://testanything.org/tap-specification.html + local bail_out="Bail out! " + local message="$1" + + say_color error $bail_out "$message" + _error_exit +} + say () { say_color info "$*" } @@ -612,9 +624,7 @@ if test -n "$HARNESS_ACTIVE" then if test "$verbose" = t || test -n "$verbose_only" then - printf 'Bail out! %s\n' \ - 'verbose mode forbidden under TAP harness; try --verbose-log' - exit 1 + BAIL_OUT 'verbose mode forbidden under TAP harness; try --verbose-log' fi fi @@ -1402,7 +1412,7 @@ then fi elif test_bool_env GIT_TEST_PASSING_SANITIZE_LEAK false then - error "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak" + BAIL_OUT "GIT_TEST_PASSING_SANITIZE_LEAK=true has no effect except when compiled with SANITIZE=leak" fi # Last-minute variable setup