From patchwork Tue Jun 30 15:03:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11634257 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3E2E56C1 for ; Tue, 30 Jun 2020 15:03:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1FD1C20759 for ; Tue, 30 Jun 2020 15:03:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pzyDpelu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731710AbgF3PDb (ORCPT ); Tue, 30 Jun 2020 11:03:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbgF3PDa (ORCPT ); Tue, 30 Jun 2020 11:03:30 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BDA9C03E979 for ; Tue, 30 Jun 2020 08:03:30 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id c139so18829080qkg.12 for ; Tue, 30 Jun 2020 08:03:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=qSDefz+bSUh6eorg/Tb0dLtP1P2UtpxQubXdHLv8sAA=; b=pzyDpeluK772xwi1C5uhl2yMJ9E+GkCzibig5Mxqfe56lwDeskQF4Fiw8GScKdc8Lr uEbKdCOM+kwl9qX7XRMkViP2r2JpS9SUZiVjKQqfalSLuodsvNV3FMHM4Ho27AFq9OWW C6DqAvKkC+fiksSMkP08T9D9m+Q0l4z8qQ3WQgMmPzXes7NpQ//8pbGJsO34grua3+wr OKPvyzsExnd7B5p/8PqXd1QyZeisN1nQqFLR88nsmQh/FMP+sP6RvaXiFAqk5vsXiCAn K9JCBvPy6mrVX5EDRp7FD6XEjaMdxHzvC0huS0bxRMWuQ0GaxXTThca7ylMmAgMG11Rb pelQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qSDefz+bSUh6eorg/Tb0dLtP1P2UtpxQubXdHLv8sAA=; b=Wr3/dlkdx91W7FIPjDRNF7GTJI8ka+kgKTIC8RkmZC0gImlemwByxUuarBNBX3wHMl 2hy2hHddXUpfdySlfSpIOCI6cCI8weER7xdPp8e0MytdAeNn7T8b23Ax8+EZBkUMTW4T bccM33C2V1cWsE4Ci4coYHvlbFX/0cO4wz/pIp0GxQ5wAVLr3fItJ20R4ueqrcVxR35Y 5ZwLZHhGkJJFqtcK2MTFWzHtTmBoYngxt6gPqGqJG553S4XOKkxWm4aqxh24eb3O1bKk ItqQriQWyLFcodjvWRYNBtonEfApgzEsKBdd6keykyUuBG6TYOcwRsh/MRIAj3GedD0i SOdA== X-Gm-Message-State: AOAM530+5LusuvFfo23SecT+1j9frhretgavskh/a7pgrZEko4U/9iRx FwHXxagDoTpSIUm5QGvdJy/QBaw7vD4= X-Google-Smtp-Source: ABdhPJyAKguVYfjMbHE22F3OIYLca0w4HR/+K8goTpsexTNjg/0yNC1oCaxFpLGZZu4qxc0feuvDTw== X-Received: by 2002:a37:6643:: with SMTP id a64mr20117604qkc.397.1593529409658; Tue, 30 Jun 2020 08:03:29 -0700 (PDT) Received: from archbookpro.phub.net.cable.rogers.com (CPEc05627352ede-CM185933998587.cpe.net.cable.rogers.com. [174.112.146.193]) by smtp.gmail.com with ESMTPSA id p66sm3209626qkf.58.2020.06.30.08.03.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:03:29 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH 1/5] t3701: stop using `env` in force_color() Date: Tue, 30 Jun 2020 11:03:15 -0400 Message-Id: <67d5b93fdaab7f73f352293372ee3d71fb7c1409.1593529394.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a future patch, we plan on making the test_must_fail()-family of functions accept only git commands. Even though force_color() wraps an invocation of `env git`, test_must_fail() will not be able to figure this out since it will assume that force_color() is just some random function which is disallowed. Instead of using `env` in force_color() (which does not support shell functions), export the environment variables in a subshell. Write the invocation as `force_color test_must_fail git ...` since shell functions are now supported. Signed-off-by: Denton Liu --- t/t3701-add-interactive.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 49decbac71..c4c1e9b603 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -31,7 +31,13 @@ diff_cmp () { # indicates a dumb terminal, so we set that variable, too. force_color () { - env GIT_PAGER_IN_USE=true TERM=vt100 "$@" + ( + GIT_PAGER_IN_USE=true && + export GIT_PAGER_IN_USE && + TERM=vt100 && + export TERM && + "$@" + ) } test_expect_success 'setup (initial)' ' @@ -604,7 +610,7 @@ test_expect_success 'detect bogus diffFilter output' ' echo content >test && test_config interactive.diffFilter "sed 1d" && printf y >y && - test_must_fail force_color git add -p X-Patchwork-Id: 11634263 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7D1214E3 for ; Tue, 30 Jun 2020 15:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C02D120759 for ; Tue, 30 Jun 2020 15:03:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cUcNGf5x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389232AbgF3PDe (ORCPT ); Tue, 30 Jun 2020 11:03:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbgF3PDc (ORCPT ); Tue, 30 Jun 2020 11:03:32 -0400 Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16D21C061755 for ; Tue, 30 Jun 2020 08:03:32 -0700 (PDT) Received: by mail-qk1-x744.google.com with SMTP id 145so16376201qke.9 for ; Tue, 30 Jun 2020 08:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=sgo7WNu2r3te8+uwmFrMuip8L4ZIsuLTKZ/ygE5LUj0=; b=cUcNGf5xWIZ0I+RnKdTxmaZVizRRIPZlA2vncI3qQJMmvTO75rAv2oZYiI2qBI7cZb XR5+fwSelyopTrg87MUBUcB1tlYEjWw8yb/daRnkUKBZjyJvWle4brMiITNsdaDb5WSy 1x2KAR77FqwTEAFSOgub033jm6aTn9mDcq/KEBTUlz9ZH6h4XmNhyS5Hf0FyXEDPZmEk 43SZ/LUxA3B7Z8BQ17OXSO7Nt2dJKpFChrAysFnahvY+sV7MT8dXUX8j9bPA80oZcq7D 1LgIQe4Zm3QLJTbTnOjCguNup62vnb/SuIfHoLa17MqqQg8o2CEhlCRRK915ySLdCPEl UYkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sgo7WNu2r3te8+uwmFrMuip8L4ZIsuLTKZ/ygE5LUj0=; b=bO9Q7s2EGEIZcsv7j0+YW/gLnd6TzYKZQo/HparLE7WOZEMXFc5KxhWUeBKa0NJ622 Ytp9CwjRvc1wWz6CXuye385adWQ4lftljjTZtIbQUES2alxmZ98xP6MvJhJd68jD4eiM leTnWPDgEJYqB+pmWXr0kalAnmv4FR6tWyDRewwewPwMvHnnMXY2Z7T5ajDb+PvmuJB5 zD4kt1TT0KqHIAUfhBxlEMpHoo5G1VXlTX5Ok6FoeLZ/oRlDNkCJ6SRSx3eOBUYMZrSd Jzu+QMtEEYAqZgvQwuPB6ghn2Qikdk3zX2swwabX71ywJv8GseqYrRXWJ220qHwkTifG sQRQ== X-Gm-Message-State: AOAM532bMKttq2hMj/YKZmMcZ4ugEvxAyKDVEHLTFwlQyYxgzMBlWURC 6VBiWSisjgYGN46n2uZlPN7+nRXoZb4= X-Google-Smtp-Source: ABdhPJzGqC/ekKH4qdP69dZ2LaB5k2QUUyC7RZtavpDOQKd1EeE6gLMQl4374SDKrhFYlSmpT6PUQw== X-Received: by 2002:a05:620a:120b:: with SMTP id u11mr19901275qkj.243.1593529410975; Tue, 30 Jun 2020 08:03:30 -0700 (PDT) Received: from archbookpro.phub.net.cable.rogers.com (CPEc05627352ede-CM185933998587.cpe.net.cable.rogers.com. [174.112.146.193]) by smtp.gmail.com with ESMTPSA id p66sm3209626qkf.58.2020.06.30.08.03.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:03:30 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH 2/5] t5324: reorder `run_with_limited_open_files test_might_fail` Date: Tue, 30 Jun 2020 11:03:16 -0400 Message-Id: X-Mailer: git-send-email 2.27.0.383.g050319c2ae In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the future, we plan on only allowing `test_might_fail` to work on a restricted subset of commands, including `git`. Reorder the commands so that `run_with_limited_open_files` comes before `test_might_fail`. This way, `test_might_fail` operates on a git command. Signed-off-by: Denton Liu --- t/t5324-split-commit-graph.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t5324-split-commit-graph.sh b/t/t5324-split-commit-graph.sh index 269d0964a3..9b850ea907 100755 --- a/t/t5324-split-commit-graph.sh +++ b/t/t5324-split-commit-graph.sh @@ -399,7 +399,7 @@ test_expect_success ULIMIT_FILE_DESCRIPTORS 'handles file descriptor exhaustion' for i in $(test_seq 64) do test_commit $i && - test_might_fail run_with_limited_open_files git commit-graph write \ + run_with_limited_open_files test_might_fail git commit-graph write \ --split=no-merge --reachable || return 1 done ) From patchwork Tue Jun 30 15:03:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11634261 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4E75E6C1 for ; Tue, 30 Jun 2020 15:03:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 36CE12073E for ; Tue, 30 Jun 2020 15:03:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RlYFB/8V" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389236AbgF3PDf (ORCPT ); Tue, 30 Jun 2020 11:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58926 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731720AbgF3PDd (ORCPT ); Tue, 30 Jun 2020 11:03:33 -0400 Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1230BC03E979 for ; Tue, 30 Jun 2020 08:03:33 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id m8so5193876qvk.7 for ; Tue, 30 Jun 2020 08:03:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=S5HXV90BTLysKS2/1O+EbNfR5SQj4JWEsCACgTL/Vcw=; b=RlYFB/8V9LHiiQfL8l8nOSt2i7H9SbvG3zLa33FfatP5iIeBbt0LI+spNyCW7b4rsE 2HpQkz/cKshqb3b8FLqISxj8x2UsnYW38CoM4r30F2vavk/+Thw3VomjbkovUxIpsl/A njo4fWdwC0mnbZku0oIOoV8NRrHb/Ozg4uoi9dr4LjTStBGsRuF6EfRMM8YsNRaO5eZS sBRz2z1yJjnNxjdkyCPKvRtK1IiYKCG4che581tL7jESBrlGQGNZvcUMoLG4xFWYSj9U kdERAD6xFjjJJThc4R8MSkGSuwD7MAOsqrccuE9EQ+GbAnIrwcVHtpNpLyAydphEhaIe eeoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=S5HXV90BTLysKS2/1O+EbNfR5SQj4JWEsCACgTL/Vcw=; b=sls3/w1xnOYoFuSGy0vdIcDzaohwyJaYwyibfK4jgKWnMHzQBbvvODcLapjsHyF0Ik N6y9PWl3dTj0BImjuVeQcf7BcyXF5DicCuZCPXTxid9kvh8KEpw6VGXyTvKxIzIT6Z1D Mj3fsYSj654TsnizO+zpB9VcdlrDAVxHSY6NAIU+24WU/gEHg8bvIE+in5vIsk3labyw PJ1qMtKaqlWOkunAaHSxG4/MqKLf+5fpq5NKpB8YS7fZ3BimI05OACKyyj6MgAY5WvYN Bklr3nezfSml7tdyTZgGkSGFYCDnxKgojzFulRIITiuW0pbiqgdtRGLW79iP6bwnKhZB ffoQ== X-Gm-Message-State: AOAM530iADheXiWvSOOh8+2KLdcJz/XkxbuC4KUm+ihae2vh1u1pmnp/ FeeX0fk8jovp6kWWLlIZ4277RnOUWAw= X-Google-Smtp-Source: ABdhPJz1bpPufOvD40lJlVIQgkKkO2bXkrnsN/P6ZWZt3uMThH8yxkMWeeOE5CII0oML9YDodgcGTw== X-Received: by 2002:a0c:e6e3:: with SMTP id m3mr15438300qvn.162.1593529412007; Tue, 30 Jun 2020 08:03:32 -0700 (PDT) Received: from archbookpro.phub.net.cable.rogers.com (CPEc05627352ede-CM185933998587.cpe.net.cable.rogers.com. [174.112.146.193]) by smtp.gmail.com with ESMTPSA id p66sm3209626qkf.58.2020.06.30.08.03.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:03:31 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH 3/5] t7107: don't use test_must_fail() Date: Tue, 30 Jun 2020 11:03:17 -0400 Message-Id: <74bc29b18b2dd2352843e675431e7685c0495359.1593529394.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org We had a `test_must_fail verify_expect`. However, the git command in verify_expect() was not expected to fail; the test_cmp() was the failing command. Be more precise about testing failure by accepting an optional first argument of '!' which causes the result of the file comparison to be negated. Signed-off-by: Denton Liu --- t/t7107-reset-pathspec-file.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/t/t7107-reset-pathspec-file.sh b/t/t7107-reset-pathspec-file.sh index cad3a9de9e..15ccb14f7e 100755 --- a/t/t7107-reset-pathspec-file.sh +++ b/t/t7107-reset-pathspec-file.sh @@ -22,7 +22,12 @@ restore_checkpoint () { verify_expect () { git status --porcelain -- fileA.t fileB.t fileC.t fileD.t >actual && - test_cmp expect actual + if test "x$1" = 'x!' + then + ! test_cmp expect actual + else + test_cmp expect actual + fi } test_expect_success '--pathspec-from-file from stdin' ' @@ -131,7 +136,7 @@ test_expect_success 'quotes not compatible with --pathspec-file-nul' ' cat >expect <<-\EOF && D fileA.t EOF - test_must_fail verify_expect + verify_expect ! ' test_expect_success 'only touches what was listed' ' From patchwork Tue Jun 30 15:03:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11634265 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B15E618 for ; Tue, 30 Jun 2020 15:03:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1F7D12073E for ; Tue, 30 Jun 2020 15:03:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SjT1dmIe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389239AbgF3PDh (ORCPT ); Tue, 30 Jun 2020 11:03:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbgF3PDe (ORCPT ); Tue, 30 Jun 2020 11:03:34 -0400 Received: from mail-qt1-x841.google.com (mail-qt1-x841.google.com [IPv6:2607:f8b0:4864:20::841]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C9D5EC061755 for ; Tue, 30 Jun 2020 08:03:34 -0700 (PDT) Received: by mail-qt1-x841.google.com with SMTP id u12so15768973qth.12 for ; Tue, 30 Jun 2020 08:03:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=oAbR0wwvA+x9vSI9jWWmVAcNopC8aAbgSqCtK37T0D8=; b=SjT1dmIevSojNC+BmBXPjmimQ5kXDT/P0PTGDjlwl3I9mEleBi5jXmLDE6OMyqQKoo 9MPqgufThJmRRu7mBbGuiX03ZrQWMIpPonFCjOTphHcvq8aThYhKquZkOjTmbwohQDMj Fd4hVt1IExjDVhD0oSJZuPuzDX3MjNX0kz8G08/ZR3eKWBN1+gNVXxhe08+eQFCXNrU2 HkHxy5MyeJ3ehE9MfCxClUYyCgjcjaK4FR8GvPxAlOy4MLN7x/DR2ZTS0HeV2gVzB+Aj ENZs+seEPD3jn0kOFDJylUh1jY3Vtz5K7bVoP3WfmMXim+aLkXtqGlBeC5qOCvJjbjvv JnGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oAbR0wwvA+x9vSI9jWWmVAcNopC8aAbgSqCtK37T0D8=; b=cZO6vhwABAyCG5IrEsVvpGqIEgrXenHNKE1iNA81UblKQCz4DPtHvX/fywMdiRXYW3 z/5P3+U8cBdJbCigCzb527vSFQwF7N1jNU8vUXH2UXfLeUVFBClljI3CSN9d1zeEL3nN tAegt1vy5SrN+8B3vi1ByBzL428LwtWMmX00EekxRAVRUUQ+/fFFq6tRCRXIR5TxDm+F Na/tkfTJCp8M/UG9O0TLrECYdBoSz+VWiKw/M1229h/cZ/BBJ/b+uzH6T2MYcO4rEWd1 S94Ladow3om61B8Fsm/glWRah4TIwOvjQaguMFJwQ3D2+IRAUcBBBhsXs9okHKbq8aMU o4pA== X-Gm-Message-State: AOAM530kHiX8qROr7CuPE+mqJ8NQ1oopcH3f53ekmbaULDmg5jOnR0Gi lreMH09UR46HG9QUBqztwdbZ2hVI3s8= X-Google-Smtp-Source: ABdhPJyj6ryd+0xNfEc9SldGDbDcxrW/vemZK5jzzF8NagkB0ImFvGc0mJdkECJLTKeQ97woyenFjw== X-Received: by 2002:ac8:1a12:: with SMTP id v18mr21648430qtj.347.1593529413316; Tue, 30 Jun 2020 08:03:33 -0700 (PDT) Received: from archbookpro.phub.net.cable.rogers.com (CPEc05627352ede-CM185933998587.cpe.net.cable.rogers.com. [174.112.146.193]) by smtp.gmail.com with ESMTPSA id p66sm3209626qkf.58.2020.06.30.08.03.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:03:32 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH 4/5] t9834: remove use of `test_might_fail p4` Date: Tue, 30 Jun 2020 11:03:18 -0400 Message-Id: <1287798e691bd3be1ac094bacae5149560c9e6df.1593529394.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org The test_must_fail() family of functions (including test_might_fail()) should only be used on git commands. Replace test_might_fail() with a compound command wrapping the old p4 invocation that always returns 0. Signed-off-by: Denton Liu --- t/t9834-git-p4-file-dir-bug.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/t9834-git-p4-file-dir-bug.sh b/t/t9834-git-p4-file-dir-bug.sh index 031e1f8668..dac67e89d7 100755 --- a/t/t9834-git-p4-file-dir-bug.sh +++ b/t/t9834-git-p4-file-dir-bug.sh @@ -10,7 +10,7 @@ repository.' test_expect_success 'start p4d' ' start_p4d && - test_might_fail p4 configure set submit.collision.check=0 + { p4 configure set submit.collision.check=0 || :; } ' test_expect_success 'init depot' ' From patchwork Tue Jun 30 15:03:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11634267 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 30313618 for ; Tue, 30 Jun 2020 15:03:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1840920759 for ; Tue, 30 Jun 2020 15:03:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VrA2owW3" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389242AbgF3PDk (ORCPT ); Tue, 30 Jun 2020 11:03:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731592AbgF3PDk (ORCPT ); Tue, 30 Jun 2020 11:03:40 -0400 Received: from mail-qt1-x844.google.com (mail-qt1-x844.google.com [IPv6:2607:f8b0:4864:20::844]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F3A0C061755 for ; Tue, 30 Jun 2020 08:03:40 -0700 (PDT) Received: by mail-qt1-x844.google.com with SMTP id e12so15760850qtr.9 for ; Tue, 30 Jun 2020 08:03:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=fh2dfIVEBOy9PppBa/lU0BMRIiOvh5Fs5PbqhuwLFAw=; b=VrA2owW3TmxGs/IOMlwxxzDEQW8muqpB+ozzlyDO7ciESD2+D/kl0mgmD+TULpyxyt wfkp5X/Z2H0k2z6AFGT+oiPC1FbKU8uqIB8861rhQqqKlgzGGw/Fk5Mw+V/gutEvEKnG APbPkttTe28p4mTZeedJA6UwOE/Fp29RDoLhvOAzTE2qEGf+b+f4n4hCK7VmCAz+4uth VMrTGPBBFIRP+j0oN0LFVoEI5wxs/erQxwkH+2KgWYOFdtZc308Fq9UOzD0ttrth2l1f Sc3KYRN21kkECyRIVA7PTPjiheJKvt6GQXW49BwO9HlHzNWim3X+rGwg3ln0geRBQL3h lyPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=fh2dfIVEBOy9PppBa/lU0BMRIiOvh5Fs5PbqhuwLFAw=; b=fpig3PAiUvniRFsPT4ws+o+ApQcXpWD+cWPT2jtwjdZMX+TsqwzTlRPVgRL6VowWBv 71DA4mUilyqaezpmhooWgUAbextanQGgsiWGbLWP5BFLqZeVqNsZD7xPO8oeQMINiXMM P2REERVBSStH6LVG6SJ/0+P0B3ldejv04MuYA1aAh4wwhek6zVDxCpG4Y5w2jbtryyzP 13g+ZEQ6ZBNqPwHAFKAOrZW2TlYz9GPR+1uJSx9strEP8sNu06VEHwvfzZV8dh34shiD VOSfm2uC+i/P3JaxYzNkG1IPYyQ6SnP2xSVXygrX003P583sAwswU7m3MA3/98IyZK9v IN+A== X-Gm-Message-State: AOAM533jTvtXrZFsexhK1gHL//QW7DuzGrKYoZb0aSiKTF0ZW9YC3ITX UjZOoDEUErydYOY6ORZkbRlhhg/EIuk= X-Google-Smtp-Source: ABdhPJyl+kAugjenrj6h87Ieoes1B/EeXQ1Vfqdr8btQUJYXr2Y7jHEElIbijJuJUnOM+t8phPBPfg== X-Received: by 2002:ac8:7343:: with SMTP id q3mr22440717qtp.165.1593529414285; Tue, 30 Jun 2020 08:03:34 -0700 (PDT) Received: from archbookpro.phub.net.cable.rogers.com (CPEc05627352ede-CM185933998587.cpe.net.cable.rogers.com. [174.112.146.193]) by smtp.gmail.com with ESMTPSA id p66sm3209626qkf.58.2020.06.30.08.03.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 08:03:33 -0700 (PDT) From: Denton Liu To: Git Mailing List Subject: [PATCH 5/5] test-lib-functions: restrict test_must_fail usage Date: Tue, 30 Jun 2020 11:03:19 -0400 Message-Id: <01e29450fe51a4ba13e07c611d8795ffd0282b9e.1593529394.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.383.g050319c2ae In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In previous commits, we removed the usage of test_must_fail() for most commands except for a set of pre-approved commands. Since that's done, only allow test_must_fail() to run those pre-approved commands. Obviously, we should allow `git`. We allow `__git*` as some completion functions return an error code that comes from a git invocation. It's good to avoid using test_must_fail unnecessarily but it wouldn't hurt to err on the side of caution when we're potentially wrapping a git command (like in these case). We also allow `test-tool` and `test-svn-fe` because these are helper commands that are written by us and we want to catch their failure. Finally, we allow `test_terminal` because `test_terminal` just wraps around git commands. Also, we cannot rewrite `test_must_fail test_terminal` as `test_terminal test_must_fail` because test_must_fail() is a shell function and as a result, it cannot be invoked from the test-terminal Perl script. We opted to explicitly list the above tools instead of using a catch-all such as `test[-_]*` because we want to be as restrictive as possible so that in the future, someone would not accidentally introduce an unrelated usage of test_must_fail() on an "unapproved" command. Signed-off-by: Denton Liu --- t/t0000-basic.sh | 18 ++++++++++++++++++ t/test-lib-functions.sh | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 2ff176cd5d..f5e4fb515d 100755 --- a/t/t0000-basic.sh +++ b/t/t0000-basic.sh @@ -1271,4 +1271,22 @@ test_expect_success 'very long name in the index handled sanely' ' test $len = 4098 ' +test_expect_success 'test_must_fail on a failing git command' ' + test_must_fail git notacommand +' + +test_expect_success 'test_must_fail on a failing git command with env' ' + test_must_fail env var1=a var2=b env var3=c git notacommand +' + +test_expect_success 'test_must_fail rejects a non-git command' ' + ! test_must_fail grep ^$ notafile 2>err && + grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err +' + +test_expect_success 'test_must_fail rejects a non-git command with env' ' + ! test_must_fail env var1=a var2=b env var3=c grep ^$ notafile 2>err && + grep -F "test_must_fail: only '"'"'git'"'"' is allowed" err +' + test_done diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index 3103be8a32..16596b28ba 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -798,6 +798,31 @@ list_contains () { return 1 } +# Returns success if the arguments indicate that a command should be +# accepted by test_must_fail(). If the command is run with env, the env +# and its corresponding variable settings will be stripped before we +# test the command being run. +test_must_fail_acceptable () { + while test "$1" = "env" + do + shift + while test $# -gt 0 + do + case "$1" in *?=*) ;; *) break ;; esac + shift + done + done + + case "$1" in + git|__git*|test-tool|test-svn-fe|test_terminal) + return 0 + ;; + *) + return 1 + ;; + esac +} + # This is not among top-level (test_expect_success | test_expect_failure) # but is a prefix that can be used in the test script, like: # @@ -817,6 +842,15 @@ list_contains () { # Multiple signals can be specified as a comma separated list. # Currently recognized signal names are: sigpipe, success. # (Don't use 'success', use 'test_might_fail' instead.) +# +# Do not use this to run anything but "git" and other specific testable +# commands (see test_must_fail_acceptable()). We are not in the +# business of vetting system supplied commands -- in other words, this +# is wrong: +# +# test_must_fail grep pattern output +# +# Just use '!' instead. test_must_fail () { case "$1" in @@ -828,6 +862,11 @@ test_must_fail () { _test_ok= ;; esac + if ! test_must_fail_acceptable "$@" + then + echo >&7 "test_must_fail: only 'git' is allowed: $*" + return 1 + fi "$@" 2>&7 exit_code=$? if test $exit_code -eq 0 && ! list_contains "$_test_ok" success