From patchwork Wed Nov 18 19:04:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11915603 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2A27C5519F for ; Wed, 18 Nov 2020 19:04:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F17E20B1F for ; Wed, 18 Nov 2020 19:04:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pmDb/R8a" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgKRTEc (ORCPT ); Wed, 18 Nov 2020 14:04:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbgKRTEb (ORCPT ); Wed, 18 Nov 2020 14:04:31 -0500 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F8EC0613D4 for ; Wed, 18 Nov 2020 11:04:31 -0800 (PST) Received: by mail-wm1-x341.google.com with SMTP id c9so4078638wml.5 for ; Wed, 18 Nov 2020 11:04:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vwK2lOHer0ivTS7WMTALZhkWdFn5jBdMUCU7hbO2JPE=; b=pmDb/R8aJmdo2DCy0umPSGPvAKLF+GDGtft3U/F4h4+aES69ph7aNTrvAfgHCPcxDd Utj3/8/gCd8SwhB26SAsAJzVnnFapNvIEyCU6H7XJVBFNUtwQxe06v3sImBefMV65Amv Rbiu1nuXZFFEvDMKH3FAhutOkjtf30jIlYRVCtLyem4EW7Xip+W1KcbxpwIGVrCLOH2a qVXTNu3CtY02TQFP73FmRGUYRhqad3x32osgk0Ln0QVQFvyhhwyi9C0JNZ85VXK6LOHv 3aGBmhW70/s06CJKwju8tKZF/WKACrEA0YcpzoKMzBDaWqYQy9O6IooB+x07ATRx+OtD 7TWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=vwK2lOHer0ivTS7WMTALZhkWdFn5jBdMUCU7hbO2JPE=; b=BQ9J9ChGsUO17M+WqXqSW0PjvlhMm2NW4C9YRkR6n4oZ7aHx1/xIpYw90NZUnax3ev 2xXVApIHeOWrZKVGOzyIgtPNYZJsAhvNf7SJ3k8cCJCDcUGPj0WM2+nivTQmwX5Ctcux lkyHG2swaduYCM7Pxx7G2qIjA0G0B3tXmQKlFdmAm2EwFc8arBzaUBlFbnjXICBvNH2r GddPq3qek/zPtXCNi5Y/vMScnI85skkblnTPLk9wZIuO/lkpJPUeg7qdShaVIDzOB1jI nqAOsMtOzyCYnGleRVMBEbdD0zVc0ZdC5MgAN4pImQD+OgopLNvDCox8YATOG9oeJ6wT AlTw== X-Gm-Message-State: AOAM530Q9Grc9JkMEO7qy1O9Hip7ZOMWqrcohAOVZgtGrSYhK0H/EdQt z/oOAR3AoGeJRJpQVD0wkp8sekA/Nbc= X-Google-Smtp-Source: ABdhPJye703FxNGd3aujxOsctWejnDHBj8OKBeKn1+ErqBD7RMctkhMMQsLLsHYUbVz5NT7T56i4LQ== X-Received: by 2002:a1c:7d10:: with SMTP id y16mr609153wmc.142.1605726269836; Wed, 18 Nov 2020 11:04:29 -0800 (PST) Received: from localhost.localdomain (78-131-14-45.pool.digikabel.hu. [78.131.14.45]) by smtp.gmail.com with ESMTPSA id n23sm5313432wmk.24.2020.11.18.11.04.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 11:04:29 -0800 (PST) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Jeff King , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 1/2] tests: make sure nested lazy prereqs work reliably Date: Wed, 18 Nov 2020 20:04:13 +0100 Message-Id: <20201118190414.32616-1-szeder.dev@gmail.com> X-Mailer: git-send-email 2.29.2.612.g41c40d3f73 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Some test prereqs depend on other prereqs, so in a couple of cases we have nested prereqs that look something like this: test_lazy_prereq FOO ' test_have_prereq BAR && check-foo ' This can be problematic, because lazy prereqs are evaluated in the '$TRASH_DIRECTORY/prereq-test-dir' directory, which is the same for every prereq, and which is automatically removed after the prereq has been evaluated. So if the inner prereq (BAR above) is a lazy prereq that hasn't been evaluated yet, then after its evaluation the 'prereq-test-dir' shared with the outer prereq will be removed. Consequently, 'check-foo' will find itself in a non-existing directory, and won't be able to create/access any files in its cwd, which could result in an unfulfilled outer prereq. Luckily, this doesn't affect any of our current nested prereqs, either because the inner prereq is not a lazy prereq (e.g. MINGW, CYGWIN or PERL), or because the outer prereq happens to be checked without touching any paths in its cwd (GPGSM and RFC1991 in 'lib-gpg.sh'). So to prevent nested prereqs from interfering with each other let's evaluate each prereq in its own dedicated directory by appending the prereq's name to the directory name, e.g. 'prereq-test-dir-SYMLINKS'. In the test we check not only that the prereq test dir is still there, but also that the inner prereq can't mess with the outer prereq's files. Signed-off-by: SZEDER Gábor --- This came up while looking into: https://public-inbox.org/git/nycvar.QRO.7.76.6.2011152252520.18437@tvgsbejvaqbjf.bet/ because this did become an issue when I made the JGIT prereq depend on SHA1. t/t0000-basic.sh | 21 +++++++++++++++++++++ t/test-lib-functions.sh | 6 +++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 923281af93..4031a0e3fc 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -831,6 +831,27 @@ then exit 1 fi +test_lazy_prereq NESTED_INNER ' + >inner && + rm -f outer +' +test_lazy_prereq NESTED_PREREQ ' + >outer && + test_have_prereq NESTED_INNER && + echo "can create new file in cwd" >file && + test -f outer && + test ! -f inner +' +test_expect_success NESTED_PREREQ 'evaluating nested lazy prereqs dont interfere with each other' ' + nestedworks=yes +' + +if test -z "$GIT_TEST_FAIL_PREREQS_INTERNAL" && test "$nestedworks" != yes +then + say 'bug in test framework: nested lazy prerequisites do not work' + exit 1 +fi + test_expect_success 'lazy prereqs do not turn off tracing' " run_sub_test_lib_test lazy-prereq-and-tracing \ 'lazy prereqs and -x' -v -x <<-\\EOF && diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 8d59b90348..94395b9807 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -474,15 +474,15 @@ test_lazy_prereq () { test_run_lazy_prereq_ () { script=' -mkdir -p "$TRASH_DIRECTORY/prereq-test-dir" && +mkdir -p "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" && ( - cd "$TRASH_DIRECTORY/prereq-test-dir" &&'"$2"' + cd "$TRASH_DIRECTORY/prereq-test-dir-'"$1"'" &&'"$2"' )' say >&3 "checking prerequisite: $1" say >&3 "$script" test_eval_ "$script" eval_ret=$? - rm -rf "$TRASH_DIRECTORY/prereq-test-dir" + rm -rf "$TRASH_DIRECTORY/prereq-test-dir-$1" if test "$eval_ret" = 0; then say >&3 "prerequisite $1 ok" else From patchwork Wed Nov 18 19:04:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?SZEDER_G=C3=A1bor?= X-Patchwork-Id: 11915605 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B9A1C5519F for ; Wed, 18 Nov 2020 19:04:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FE3A21D1A for ; Wed, 18 Nov 2020 19:04:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P3akTZYU" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726484AbgKRTEf (ORCPT ); Wed, 18 Nov 2020 14:04:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726268AbgKRTEe (ORCPT ); Wed, 18 Nov 2020 14:04:34 -0500 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC465C0613D6 for ; Wed, 18 Nov 2020 11:04:34 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id j7so3305165wrp.3 for ; Wed, 18 Nov 2020 11:04:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=96n3bDmMhKAbN8kxt2oYeVvRkYgif/tYg2S4TMMsPWU=; b=P3akTZYU2E8sGO6jPvCA2PkKepisEM+2CUdi6a0t4UB73zyjVw2hAra+3FLg3DifEJ JUrAZlN/SvbjVtRm0sxKb5B9jMLT361k3KiHKr6htCbccIXKkCkRQIeXbcWhIrmjiCV/ GMWYQ7NmGX2ItB/fejy7IbBBCTnrJufhV0NfLigeC+Py6EyddcFi86pH0goX17OK9Uyr KnlzQ3x9w/axJ943YiQfsuHX8MnHcWKhuNCqSek+vcv8ZZJw8TlvPJ9L3je1enpAjnaX s4EKCXFS//0oKCXYvNQXLsLih33XJfTmIN2WpdOTZzZBMG7DEGBUaVDEDSC6TNXCsmMU JNgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=96n3bDmMhKAbN8kxt2oYeVvRkYgif/tYg2S4TMMsPWU=; b=GP4ZgVJ7Ik5S3XB5FIVmgnh9KN4NLaTulhO/MLlNfuTOmG+5WWdWZ0mioZ9ZIkEUtG vmJyAICK9AadwV10O20lY6QP8ksA2D6FspJ0jdkz3UOCBmKE8mOFMSlFKCUTpSPcAwHe we4GYhop8kdE7miQOVrPJfuciM16upIjixbdUC9jfp498pyMhuNfDT8lV5Dzqf6RCpJl LhLIXuWXXFUQad46rlBTBGY1ryhowZdtlaBUu8uesdqIRsAwMnmOzhDWhLcAkxQ0aGvw SDVZLhu4eKwkyd7j9gIuvPza33RW5WaN2Q0rvlXQk7jsj75cgPFWZ4e9GBHzGCFGBz6q EHIw== X-Gm-Message-State: AOAM5315YurCwt1e70HPvgUe05Hjc74UqBlUYnh9zEA4XMhyvFayirEf y1873sE28r09JseoAWxNLslcV+pnomM= X-Google-Smtp-Source: ABdhPJwT24QLZn5nh4DEwNwhwZcmb3X6fSV41PlduIF0i255j9eY+LeLzqH5m9hB7HuLWYzOtVndMw== X-Received: by 2002:adf:fec6:: with SMTP id q6mr6428325wrs.168.1605726272928; Wed, 18 Nov 2020 11:04:32 -0800 (PST) Received: from localhost.localdomain (78-131-14-45.pool.digikabel.hu. [78.131.14.45]) by smtp.gmail.com with ESMTPSA id n23sm5313432wmk.24.2020.11.18.11.04.30 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 18 Nov 2020 11:04:32 -0800 (PST) From: =?utf-8?q?SZEDER_G=C3=A1bor?= To: git@vger.kernel.org Cc: Junio C Hamano , Johannes Schindelin , Jeff King , =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH 2/2] tests: fix description of 'test_set_prereq' Date: Wed, 18 Nov 2020 20:04:14 +0100 Message-Id: <20201118190414.32616-2-szeder.dev@gmail.com> X-Mailer: git-send-email 2.29.2.612.g41c40d3f73 In-Reply-To: <20201118190414.32616-1-szeder.dev@gmail.com> References: <20201118190414.32616-1-szeder.dev@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org 'test_set_prereq's description claims that prereqs can be specified to 'test_expect_code', but that is not the case (it is not meant to run a test _case_, but a git command), so remove it. OTOH that description doesn't mention 'test_external' and 'test_external_without_stderr' that do accept prereqs, so mention them. Signed-off-by: SZEDER Gábor --- t/test-lib-functions.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 94395b9807..21b2ea55b7 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -423,7 +423,7 @@ write_script () { # - Explicitly using test_have_prereq. # # - Implicitly by specifying the prerequisite tag in the calls to -# test_expect_{success,failure,code}. +# test_expect_{success,failure} and test_external{,_without_stderr}. # # The single parameter is the prerequisite tag (a simple word, in all # capital letters by convention).