From patchwork Wed Jul 1 04:27:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11635257 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 CBA55174A for ; Wed, 1 Jul 2020 04:27:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B29DE20747 for ; Wed, 1 Jul 2020 04:27:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eQ2d7HfR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726092AbgGAE1a (ORCPT ); Wed, 1 Jul 2020 00:27:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbgGAE12 (ORCPT ); Wed, 1 Jul 2020 00:27:28 -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 1FAF9C03E979 for ; Tue, 30 Jun 2020 21:27:28 -0700 (PDT) Received: by mail-qv1-xf41.google.com with SMTP id m8so6203906qvk.7 for ; Tue, 30 Jun 2020 21:27:28 -0700 (PDT) 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=Kz+B32RAnkGwyFTOficrsLGlVxZI6QmjCoh7Hu/8EmU=; b=eQ2d7HfR0XCywikiVF1TUJ1Ta5+pSwCJ0FbaxyeATYtpx6NHEHyDdPLP+rM2O2fll6 fJ10Eg5PSOe7KW2xUhEuaYtOn+z4PhZxkVpST4wnut1jTDlJb13tUBZwChChyJGdacbI PQFn1lJVgrCHxeu0nX/ymPyDE5xy8kBaFVZnr0EE8D94BTL4mqKV6ozlS16pkgN9mUyo 5tdoPPrQCnZp/PcIr7vdEj8N6P68VmQp5TwJMVcnyq9+rTCT6FiFsD5eOByIbCXABA2v cw1Q20VBHbBtsyXmDLda2JMpex8NKLrspf3oNw0I9X03AjlcYIdnDeEqE6QEpd0GPNqE oOdw== 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=Kz+B32RAnkGwyFTOficrsLGlVxZI6QmjCoh7Hu/8EmU=; b=QeZkFx1LrCfzLpKE8WSAhyGyFY41VtRYLgiQ2MvaHRPUNt4tbbagnd7mgaBf63k8zf hzwowKeES54Y3LGwH5BpBcls5g+wuPUCtMSvQyez/FyuaBMLxXbyitanZDUSVBe4+W9v p5IzkhjGESao7yZZQUhUTOo/d2Zskl7DJ/aUUvPP5MvT7UXcFuyiYXrCuTQBs4Sy4jxP kq5ONGMB6DCvYhLx4Pqbzhi7GJ4vDVoRMXInp17TuZtC6ZtQbg+eNXDLGvJqw38EUSgw 1OECowdlsJYsThSP+7iS331sENWIyIZsbOYMplq4ub8rnIp7EIJ1MCE9jm044Nzuy/kj pkLg== X-Gm-Message-State: AOAM530c2HHTIv0opagM3Rs68aapbP4AZJMHfxP/X9bW7ps6VU910iW8 6Mw7sA3tEjj/GzszsOd12I440TO9reE= X-Google-Smtp-Source: ABdhPJxcx0cq7UXI/vAikCt7/4BPuFYfB8rUsB7VcGuNQYQveywiFy8k0rLigjobrkCUSff+w9ZOuw== X-Received: by 2002:a0c:f486:: with SMTP id i6mr22768096qvm.229.1593577647220; Tue, 30 Jun 2020 21:27:27 -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 x13sm4418813qts.57.2020.06.30.21.27.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 21:27:26 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [PATCH v2 1/5] t3701: stop using `env` in force_color() Date: Wed, 1 Jul 2020 00:27:09 -0400 Message-Id: <654c864691866f644ff5ec92de5bfa0701645419.1593576602.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 | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh index 49decbac71..fb73a847cb 100755 --- a/t/t3701-add-interactive.sh +++ b/t/t3701-add-interactive.sh @@ -31,7 +31,16 @@ diff_cmp () { # indicates a dumb terminal, so we set that variable, too. force_color () { - env GIT_PAGER_IN_USE=true TERM=vt100 "$@" + # The first element of $@ may be a shell function, as a result POSIX + # does not guarantee that "one-shot assignment" will not persist after + # the function call. Thus, we prevent these variables from escaping + # this function's context with this subshell. + ( + GIT_PAGER_IN_USE=true && + TERM=vt100 && + export GIT_PAGER_IN_USE TERM && + "$@" + ) } test_expect_success 'setup (initial)' ' @@ -604,7 +613,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: 11635253 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 ADAE7174A for ; Wed, 1 Jul 2020 04:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9090320760 for ; Wed, 1 Jul 2020 04:27:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vZYV//uS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726112AbgGAE1b (ORCPT ); Wed, 1 Jul 2020 00:27:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726039AbgGAE13 (ORCPT ); Wed, 1 Jul 2020 00:27:29 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECD9C03E97A for ; Tue, 30 Jun 2020 21:27:29 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id t11so8355550qvk.1 for ; Tue, 30 Jun 2020 21:27:29 -0700 (PDT) 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=sgo7WNu2r3te8+uwmFrMuip8L4ZIsuLTKZ/ygE5LUj0=; b=vZYV//uSdYrQn9140lhczlCu36WnqdnvC183t1yON/DYrpAnfWx7zDIZNzFqHUbBd4 /BtGJOP6+Zrf/01hmAVn4kcUooZwFGc2CF+ms8T82kJDSquQ+k8hLP9zGkQwygbhwOrg Abp16u/visSKBzhHVj/4AmRqs8gCMx7qOFu8zurH/Wenpt18k9cSPNJwrn8DcgAee4Jp CGV5pMZinB3qg9oIoQ4Y7D7BMUChvUWQkhID0Gz4kmFRxN4aN6P6V9X1DzcK3nwYXRla gqkqhH+CcpAQiPu2OTqN1cHRagmModtByDOH91q9ZbzXYENl0qeHlP1tpxTIR1IGnsy4 sJFw== 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=sgo7WNu2r3te8+uwmFrMuip8L4ZIsuLTKZ/ygE5LUj0=; b=OD48/wbW8yy0KTnqXZl+Ruo11+grYNUK0tsQgiCXPSk1wrVGMxGBRaZOQk4o3kMjuM l9TVwva3TfZ6dgXR1nv431nX/QVFFC2onQbhx/tY9XrNFvYF2ym9Aj17DZhHsP3CxCZU HTy4UVcrB0GeYIdAVeVxEPdpnMLrucCRnaVbhS4nfcrwGvZ25m1WpqFBVt93e+rMWk4B l3CbGqA3QoSISNJUgZ1JMkypZVtmReTX2sSJoBRuRedYPNeW4f8TCZJSSCoPsP5VZ2Dx K8ne3uC51JNqcwJOsgweFXMmcavWbINBIcjoYEkfLUgB4H34ra3gUABj5wI+EPjfggMH k6bg== X-Gm-Message-State: AOAM530tUAzhRpqe9XuYNpAId2MN9JzoMOJyWhIP6mBlTCwdkrxHooCV f/9GWauYEC9dV0BPaTi4iWoa2uDUeiQ= X-Google-Smtp-Source: ABdhPJyJdkz/V3XH+Kdg3S6zgcFLKdPhoowOKIL4xCngRojN7oC4Rd2cXTcBTkyO0VonlIC0IQSPGg== X-Received: by 2002:a0c:9e4f:: with SMTP id z15mr22304226qve.119.1593577648186; Tue, 30 Jun 2020 21:27:28 -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 x13sm4418813qts.57.2020.06.30.21.27.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 21:27:27 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [PATCH v2 2/5] t5324: reorder `run_with_limited_open_files test_might_fail` Date: Wed, 1 Jul 2020 00:27:10 -0400 Message-Id: <9ba997f7c126ed0838ca7a72f33d87f40e173fd8.1593576602.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 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 Wed Jul 1 04:27:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11635261 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 AAF49618 for ; Wed, 1 Jul 2020 04:27:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9448A20747 for ; Wed, 1 Jul 2020 04:27:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="AFTMGG+A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726325AbgGAE1h (ORCPT ); Wed, 1 Jul 2020 00:27:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41630 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726053AbgGAE1a (ORCPT ); Wed, 1 Jul 2020 00:27:30 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F3092C061755 for ; Tue, 30 Jun 2020 21:27:29 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id j10so17450730qtq.11 for ; Tue, 30 Jun 2020 21:27:29 -0700 (PDT) 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=S5HXV90BTLysKS2/1O+EbNfR5SQj4JWEsCACgTL/Vcw=; b=AFTMGG+A1XPl70dj1RWMO1DLiDq8G4OTsf9gP6LvBR9f1b9uxFc4bTMtyJeEl5a4Sh O/yZpr/9kPTjzN/K3UW7DY2KlnudTm3Unv8ljU6gctTDtpnEfQ9Pg10McABmmn//4GN+ uhfQa0Xi6gOsU4eNqbCk+yxjBC/B1RFSB3WHupVUFis/hIqRBFRw5JlAr3rSoTBZuncP wjYMxgpZXF2u0zQ14wFhQiFVwI1tUx4F7xkmy1V6REhZupokhXAeIYTEhLrrCM+4ICow gLO6ZgKKqGrijC0e9K+2OXfSiNb4NPHhZkYYZFsGwmUGYqZ8NUcv2eoq0p7Agk/v3bKS Obnw== 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=S5HXV90BTLysKS2/1O+EbNfR5SQj4JWEsCACgTL/Vcw=; b=MEQNJ5cBM0GXwYgGEFSfuuMX25ornxOorECXtl5X5AMU+SkZ5cISpDAOMQyZqq9a3P RILrE/kKp+/FvSxD1j+Qx5sRbzYycEvINmvoREQGH0HZnmDOx5C3/TaMyWEHs0PbFmUF 0bNJMcJs6wn1ntB+qxL1dIyvgyUjQlkP7uMi4XU+3NEaYYtKHaIWjYCFpYAaBRkBw+H2 4BY+avtBq+d+WItxbb9ulxmNBDX7WIA11KddjtPCjVkt6KqEllHXlRT9EKrUzc0Mzk/w USR9CZX9qleuKEf0zHEQvqkIt2GQzQM7KvYz7Xbw8R1NjtWbz+XHFZJoV1YnN2r6bq+P Uajw== X-Gm-Message-State: AOAM533QYKY6WQWNAPvE0LxlZz3xvyg6nnnls/9w55grpm9iWT9jbEbg UMQsXU2ePT12QQOhNyS1fmflJUatWrE= X-Google-Smtp-Source: ABdhPJxZf/4VO1B8H21EeWTcO6UWyCfToExkTB0I5aO/w4pDs0LHy3t+v1ruWuaGzqc0y4HqxEDAJw== X-Received: by 2002:ac8:172e:: with SMTP id w43mr13242932qtj.8.1593577649104; Tue, 30 Jun 2020 21:27: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 x13sm4418813qts.57.2020.06.30.21.27.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 21:27:28 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [PATCH v2 3/5] t7107: don't use test_must_fail() Date: Wed, 1 Jul 2020 00:27:11 -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 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 Wed Jul 1 04:27:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11635251 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 3FE0314B7 for ; Wed, 1 Jul 2020 04:27:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23061206CB for ; Wed, 1 Jul 2020 04:27:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ovQ5Kip8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726272AbgGAE1c (ORCPT ); Wed, 1 Jul 2020 00:27:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41632 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726035AbgGAE1b (ORCPT ); Wed, 1 Jul 2020 00:27:31 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D9093C03E979 for ; Tue, 30 Jun 2020 21:27:30 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id b185so10398182qkg.1 for ; Tue, 30 Jun 2020 21:27:30 -0700 (PDT) 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=oAbR0wwvA+x9vSI9jWWmVAcNopC8aAbgSqCtK37T0D8=; b=ovQ5Kip8BsyouTRkyxQexHwZfXzAt3c+eQyk0BYTW3yfUz9ZDKTLv0GAWBpcG1q6NA h+OMElNAeOjx3cyqKYtXRHxjmv6Xj4eRPqDifvRk/1ZmF6Jm00KkTywzRwvThAYYhsVb Izge5ZWxqQpcdqV21p3bixpb44sz9VdlHPiMd4ine4fJeYzkcL8+/WCi4CrYXAjEe7Hm dGSvKvV921M1TBKlvQeFc8SEFuZwiV17tJ2bnfLPFguz1CdvwXY05odxbhIjiY+xNMmf SJEY8SZFeoyu4/OBqbJqKoHlYHPFVJOs0XSTOqEEJQ/Uq5E2aknUVTJnAL68eowoUfby hFug== 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=oAbR0wwvA+x9vSI9jWWmVAcNopC8aAbgSqCtK37T0D8=; b=oa06lfg/niAqvqo2kipeJmS5stqCB6MN12SaOv90CfahnqgbBhKNj0il1zIG6ZUWjQ LzPTHQhFq//uExe66WsImzqJda5NXai5HDb8KtwNrLr/FbcZV1DAub0Ch6Pln0+A0uUf 3AE5x//mcEkeHgc9w9j/kqjx9sBeMup1U+qAjmNBZWzCD9a1M5NOnGlPUBmJIL2ICnDR 5z/bkH1jYf/S3Y7YkhJX2NnpMAlVCCuvmReBN0FPAXVgF3ZOGYRnBeZ99t8twSob7qlv jZ7WfJgDqYKQqDvM6Xa0EmMGPA/v7l25kriFY1Y1NRyw2ulVe4WDXFO/jgRIFC7cnpKu lHwQ== X-Gm-Message-State: AOAM533cBgFDwWvs3EN/si5wUcR+HjOWtTF2HPNYUMThMvhoY4fdN77I iyBE8Q4xby4LO+SIW7cfSTMIDp+glb8= X-Google-Smtp-Source: ABdhPJz6NWf9zqrOEU2IdbhWCuVKISF4gW1Z1hbyNsrr1KzlIxDY0nJ4ESaoKjBLg9O2o2q5RZLcUQ== X-Received: by 2002:a05:620a:6c3:: with SMTP id 3mr23034158qky.400.1593577650027; Tue, 30 Jun 2020 21:27: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 x13sm4418813qts.57.2020.06.30.21.27.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 21:27:29 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [PATCH v2 4/5] t9834: remove use of `test_might_fail p4` Date: Wed, 1 Jul 2020 00:27:12 -0400 Message-Id: <92d3b38428adaf0befc6eecb8a4669306d0d4276.1593576602.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 Wed Jul 1 04:27:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11635255 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 9278B618 for ; Wed, 1 Jul 2020 04:27:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B8A420760 for ; Wed, 1 Jul 2020 04:27:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="q56DMOyi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726290AbgGAE1e (ORCPT ); Wed, 1 Jul 2020 00:27:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726258AbgGAE1c (ORCPT ); Wed, 1 Jul 2020 00:27:32 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DED8FC061755 for ; Tue, 30 Jun 2020 21:27:31 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d27so17483887qtg.4 for ; Tue, 30 Jun 2020 21:27:31 -0700 (PDT) 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=3GNMzB5XGdG57c9J4z50Te/wnYLlfKFYIxSwlHCaJh0=; b=q56DMOyiyVNQDxT7Hh2a63oHmLCFqeoLcI7Qb/hdJ79oDIe70oqzJp7lY9iWms9Lv3 7LjKUL/YAIwtmupEoK0MlS6+EzFfpa96J5rwfFCj5HVt5NjyUnaoq6nlhEQx+IPrxO+D ttYznkD6gz0V9bSQ2GxPBJ2lZvHK83ksJyhEWQZHQoryfrbpFXbcpzWRtOMx5P4AzPGf 3vJ6XFlmSwPekSeqfB3muMRPKmkXD9iboX/aHia4bEjOk05pxtDxfhXF3jsLKh+81lvz PD6XX6NsZuuemSN9m7EvnyWoiZKQmDoXyMn7J7jiDh+S93ZNq5Oan5/6urjVLfnU5yOf Vmlw== 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=3GNMzB5XGdG57c9J4z50Te/wnYLlfKFYIxSwlHCaJh0=; b=MSGHQOI7OlX4JboLjcmmHYviIsRpxhfgNBxjnMNt1OVZqyRv558t8DzFUKFKaBnKiF ZVo65O0I7gwLlvHPYLxaObNua9lCJlhMOzdBQIALCt4HL6Z+Qc12DntdF18WQ1JtJusL HW9HAQAdRg7UuoBJRwA3goE2lzBlufboI1b9js/6u6YPKc07Gxx6kgNYUTxF+M7PFodK w13+s1gbT76nQu+PHZaFZylEkMTwl93NvyhrPMlP8sBwyF1eIh37prFT5K83qWVbF8kT MIEleluDvF0yVB/qqpeHfd1YaukwCEE36Ozn73qAQrKp90VoNGo5OugbVKwrPNo9o4xy aGbA== X-Gm-Message-State: AOAM533sUYj/Z98WoILroPsFYebzQQlBt95ms7PiVCeXXvHOweKAxour Oumwhb7W7A3PXyllOeXji9bx3KDqk6s= X-Google-Smtp-Source: ABdhPJwMyN3WgenilYcGGzhUEI7/FLEY38/Q7ZlWXUxPUjsigMJok8aLY2iAX2tkhOQR2vCW08amoQ== X-Received: by 2002:ac8:c8:: with SMTP id d8mr24407393qtg.221.1593577650893; Tue, 30 Jun 2020 21:27: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 x13sm4418813qts.57.2020.06.30.21.27.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jun 2020 21:27:30 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [PATCH v2 5/5] test-lib-functions: restrict test_must_fail usage Date: Wed, 1 Jul 2020 00:27:13 -0400 Message-Id: <3ebbda6c57005967b718d834aed7e3eaf00d18b4.1593576602.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 cases). 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 | 47 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/t/t0000-basic.sh b/t/t0000-basic.sh index 2ff176cd5d..90bf1dbc8d 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 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 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..b791933ffd 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -798,6 +798,37 @@ 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 () { + if test "$1" = "env" + then + shift + while test $# -gt 0 + do + case "$1" in + *?=*) + shift + ;; + *) + break + ;; + esac + done + fi + + 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 +848,17 @@ 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 +# +# Instead use '!': +# +# ! grep pattern output test_must_fail () { case "$1" in @@ -828,6 +870,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