From patchwork Tue Jul 7 06:04:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11647673 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 A3B176C1 for ; Tue, 7 Jul 2020 06:05:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8C04C20758 for ; Tue, 7 Jul 2020 06:05:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vXwG924Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728191AbgGGGFG (ORCPT ); Tue, 7 Jul 2020 02:05:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59060 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgGGGFF (ORCPT ); Tue, 7 Jul 2020 02:05:05 -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 42A62C061755 for ; Mon, 6 Jul 2020 23:05:05 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id u12so30867150qth.12 for ; Mon, 06 Jul 2020 23:05:05 -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=vXwG924Q+OS7iLJ4UnTwdlvo0raSV35Nwht2fn0GQQfZ6k6FSUN+mrfpoun1FefSQe Nj6BlZbvmuTKmA8OUpjo1vnB3/wFBH1Du1qLo4xe+vcOIUviepUAfDibr68JzDiyrd2x cY8pi9qWSWuymy77/c7JqnCz3YBvJxR8Dd1ETJT27CUu96d5n91qUjLXQe9H45MleXWv 2b3ycHFgM+wdqs/rcjmVNNWjz6pb5BwNHdQm8xR7bH5Laq7tKhkts8v4NDiD40uUTrlj A2Seq8d8p9qv4G7ZhvAjeq9837n1j5RpBX/cLjaqHDn5vOvUcsPIg07u0iUF5l3VNn5w WnPg== 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=hv+VF6ihIx2YBg66TRe7I6v9EVcSWv3yJAFSWWByquDNNy11QcELeKkhL1/KWhWicX 3I9bHRkod7g0PS8GQh8Bqc48Uguj+0w74AsUjmaT4dXqG6pBb+GAvGb1jhdqLJji3NFi mWN0J/Jp+8lbmRyFkIYbFzqk4JBN286uBvigPw647dU9NvAOlVBORZbhFVslzTtQMlAp y4Kp7L4IvvtA/xtLvF2YVXeLPLibap17t0BIPFvm5GDhOZTugK/pI2mwdcei8I1h3PWH TD+24esaFmUruQx8+pBClyw3c0FJmgQQ++9PM0LyusJKaTf993fnY1KLjQ8xXS0Eba+v FY1Q== X-Gm-Message-State: AOAM531bFTEdn7TX5p5x1XPfIXFGVBwvBu5fxcMb7LcQm8qHULJDCFrG uECE1OVRqre98TWI8zcWewXVDFaIXpU= X-Google-Smtp-Source: ABdhPJyH7EuLJmVK+sAtXXkr1KxHH4Tga5y1+2x0tK6rKI6n1FWQTg22ZMLKM7WiqrYGYAzvAAYTrg== X-Received: by 2002:ac8:4f50:: with SMTP id i16mr35393122qtw.216.1594101904348; Mon, 06 Jul 2020 23:05:04 -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 k197sm23446778qke.133.2020.07.06.23.05.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 23:05:03 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [RESEND PATCH v2 1/5] t3701: stop using `env` in force_color() Date: Tue, 7 Jul 2020 02:04:34 -0400 Message-Id: <654c864691866f644ff5ec92de5bfa0701645419.1594101831.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: 11647683 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 48249739 for ; Tue, 7 Jul 2020 06:05:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2F9A520771 for ; Tue, 7 Jul 2020 06:05:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V4ILxsAV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728210AbgGGGFJ (ORCPT ); Tue, 7 Jul 2020 02:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgGGGFG (ORCPT ); Tue, 7 Jul 2020 02:05:06 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 506BFC061755 for ; Mon, 6 Jul 2020 23:05:06 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id o38so30903175qtf.6 for ; Mon, 06 Jul 2020 23:05:06 -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=V4ILxsAVyaFUZLKot4PmigxsqRsbIWnSqFUmEjvhQ0iXOW551qLbLylgpGDLobITN4 /k6oOGeKQ23pFuWsK8xia3MMxTLY/n8KdRpmQ1a58wVlhEo/4SykaE+WRREtOKsgTUiD 6a9a3M/HZpDyrw1HymKdLgjrIkhd5YaVPQ2V3NT8orPqnlRof+fOtJe74L4/WrooU5fS 7x0lRYibECoRetILF79DN4yVFVH90OiWhXldjxpAfr+2wneMaqJoex/QXG7R/Tutyu2Q OxtJuIXepAn+PTOrGTP7udrKb2DZTmnxkoMbwL5jLE00Ii82xJO/Zzl1+vd0sXY9lO0e LIrA== 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=Yp7zK520WW1G7A3FNt1I7MjAo/sYGVyO4FjpYWbuCeykNR4fqGmT+jdUhAoG5YaFjC UmsPKQ8leU0I6czfKViOL1MZiCChYX0POdLSdUGef0xZk+WxNxCuo+CIL3xZb/sGCSan dGSzbMdap7lBizhoBxDz8SULJow0l1UkIpSb31Ox6RM2VRFDVJ50bDcLeT+yDDv5pT7s 9tR4XYNZC773hV2nW0ptEZvq6d8GFdbimMkKTXjoLxk2sss18OSomzk4QE1alDcOaZOd lc3igL2eyKaa1BuH5doXypvvFFZTbP07FwAsDGLekfGrWVll19oD8aQlIStE6r6+lM6d IXlQ== X-Gm-Message-State: AOAM532y1EmaEvU1H96C3i46BuNQwu0eXDq985TCqMcs8FLJ8UKCqgnw a2s4IPflopiV4yDd6aYZYkJf4keNMU4= X-Google-Smtp-Source: ABdhPJxLVRhYwlIpD2R4tAXNjNZds4nGgn0re/KW/0U7Qw67VA1MBd/RweE3vvZMSlFOouLuqii2FQ== X-Received: by 2002:ac8:c4e:: with SMTP id l14mr38520966qti.106.1594101905303; Mon, 06 Jul 2020 23:05:05 -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 k197sm23446778qke.133.2020.07.06.23.05.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 23:05:04 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [RESEND PATCH v2 2/5] t5324: reorder `run_with_limited_open_files test_might_fail` Date: Tue, 7 Jul 2020 02:04:35 -0400 Message-Id: <9ba997f7c126ed0838ca7a72f33d87f40e173fd8.1594101831.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 Tue Jul 7 06:04:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11647679 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 4FC3313BD for ; Tue, 7 Jul 2020 06:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3679620758 for ; Tue, 7 Jul 2020 06:05:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KsMgcEXh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728215AbgGGGFJ (ORCPT ); Tue, 7 Jul 2020 02:05:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59070 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728204AbgGGGFH (ORCPT ); Tue, 7 Jul 2020 02:05:07 -0400 Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EEC0C061794 for ; Mon, 6 Jul 2020 23:05:07 -0700 (PDT) Received: by mail-qk1-x742.google.com with SMTP id q198so37150395qka.2 for ; Mon, 06 Jul 2020 23:05:07 -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=KsMgcEXhKRMhP2aXh+JBhar/Q3kz6y/kaH4E3njhm7nlZS4FUGpt0jzFqETJ9EXPVZ 1d+0igs28g3vWh3VTbt3lb1rh8FQTWPjrDuyDC0BBRuaHcmN5fOJnahT3Hv+l1oVCOr2 H7UpNwlDiHLrt9UD6WOokVNkL48GklnwDktE4ToKhUFl2fCyezcyLupai9gESgd657bN YylkN4TE/RnAohGhwDoBgfa9YgwimsPlK+eGjDbwLXuivpAnCUvFNctbdUUWJAHr9Bpq BaSv3lNcTlF2DqbX3FRHAc1DI87GqkWHL76Tw7MOwUuaVnBICcDRFQdyOsYAOftx//Q2 3stw== 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=hSvq1Fm0RuFqJiQI8FqRojnWXjF0yUBWxDGyUlueDvJqgD9W8jbC4EERO2AiA94xve 1AObE+q1l6aISyBSw0Q1v24p/3x+DWi3jIvL5jRNfz1SsIVKVbeaJeY2SRAcw0bFoSeR sozK+SNJmRwAOj6oF5Bm8VFLv0lRNtcSwjQyJj5FYQqYkH/MxlDDPttvej76BGqfVa6c WaPRKlvNHqvEU/eL/91PXwWSvXAlcJUoPOiJmh9MBzmdiyD6yscEL9ypdCbmsIC+ZiOY VjPUKtmU3RwDe3RH2K272xDtXfbue5cXBV/yCVr+sha+ehxbgZcn7zRU7tQD8D7UDS+P KZ/w== X-Gm-Message-State: AOAM533a0lwbHm3EITvg80UehjuxHnI8DGMPExam7qA+A4rbZir2kiVL 8OtBVLXHdF+/KV3gwgwxckUMSmu5DxM= X-Google-Smtp-Source: ABdhPJy/YXbpf2XuBsqaPWv2M7x9YJxifCb1k4z50ucTy2ZqATycVLfRbIGyPirAL8tNU1ztXZ8vTg== X-Received: by 2002:a37:aa05:: with SMTP id t5mr50178353qke.451.1594101906181; Mon, 06 Jul 2020 23:05:06 -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 k197sm23446778qke.133.2020.07.06.23.05.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 23:05:05 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [RESEND PATCH v2 3/5] t7107: don't use test_must_fail() Date: Tue, 7 Jul 2020 02:04:36 -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 Tue Jul 7 06:04:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11647681 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 6F11F1709 for ; Tue, 7 Jul 2020 06:05:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5565F20771 for ; Tue, 7 Jul 2020 06:05:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XoesJG6f" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726951AbgGGGFK (ORCPT ); Tue, 7 Jul 2020 02:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59072 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728208AbgGGGFI (ORCPT ); Tue, 7 Jul 2020 02:05:08 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 66D9AC08C5DF for ; Mon, 6 Jul 2020 23:05:08 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id u12so30867205qth.12 for ; Mon, 06 Jul 2020 23:05:08 -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=XoesJG6fymy1WcibWGe7iPYJI4VwrEHnlnDSeebkbmL2iL4ro/HrHcZAqMPevvJJRb O5HmSRnlULwmfux4KGgg5ZFlRvAS4f3OUU6SEGNQMTGkP8iAS6/o/ACBNTrC0p4vPX/5 O/J1fMOVcHXtjj5CalrAJZfN6heBUjeuopTZK7aU8fDfriumD1t/Ia0NmEVKX1QkulrP /dejmncK8Ce5w7yDmCUsN8q43vEcxrYNKFP82JSBnw48kxxp9MkQ/9R1Dw4qgMGxRuRH GqlEFb6sqXrMY/bCQohpU0EftA6mx58oEwiJUKY6Nhqs2TmQZAM/PGsH4fOl9kS1Rg9p 9Mzg== 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=XNb6UBkVmB7AwRBy0uHNCntn2Uvw5xWt9uH4/3DJ4XpQWjjSbZP8exl3w7xyLPF/P9 A1gQdqvCg0YSg3A9KQ/5BhIWZZG3vOIAdNItyJw5+5ka64iQpkMloqygCkwbDQMluNwe erR33X5etKxfsLEgFaFt9g5uvcU3tyU47XOM7TBU4xeHlBgRksAvC/esjrGU1faNsELa Rh6dHzTKGFGh+EKPSe+rFMaz3rPwEDg6xRazZQ6ZVpOLN+dCBAEsSytzKgUi/6uSNC5o y9CoxNrChF1PgBXHiZB6IZf6vj3IlGkN70ltv0i6CSoSiRs+XTY2f4uLwznQnp+zvkrw usRw== X-Gm-Message-State: AOAM5322uHY2Rx58HUHGIT8KlR6bbvV7p6uJLmbvT6ikYFng4tCO2HhB jqm6+vZ9gYfBGqmXhUkMjAaSD3pLEmM= X-Google-Smtp-Source: ABdhPJwBUYKf+O82JGQFVWdbm9EdlrE1GlFzm5GFlmKypsCti33S72vQ2SwsH+7HK+iouI/wXAAxFA== X-Received: by 2002:ac8:1c42:: with SMTP id j2mr27235579qtk.323.1594101907183; Mon, 06 Jul 2020 23:05:07 -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 k197sm23446778qke.133.2020.07.06.23.05.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 23:05:06 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [RESEND PATCH v2 4/5] t9834: remove use of `test_might_fail p4` Date: Tue, 7 Jul 2020 02:04:37 -0400 Message-Id: <92d3b38428adaf0befc6eecb8a4669306d0d4276.1594101831.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 Jul 7 06:04:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11647677 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 0B81F739 for ; Tue, 7 Jul 2020 06:05:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E357220771 for ; Tue, 7 Jul 2020 06:05:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CDH8RY9I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728224AbgGGGFK (ORCPT ); Tue, 7 Jul 2020 02:05:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgGGGFJ (ORCPT ); Tue, 7 Jul 2020 02:05:09 -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 606F0C061755 for ; Mon, 6 Jul 2020 23:05:09 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id d27so30894700qtg.4 for ; Mon, 06 Jul 2020 23:05:09 -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=CDH8RY9I/dT2tduZ9P0AHk13+WIvJectPWfDlrFeYU8HPB9FMMG2vFwEWRRO46gIB7 E+MA1hYbXH6HYrNwhhm+rbODSDhnu6rQQr6U5tW5TkRuZ5vRr3wt8I6VsJo6oy5mx5Qw rAQtLDZR77wgrE7qdQ1nAEw6yw9tCHHikDHOmeLhxUxurFiezWHixJYYx6JKT1tg3Q4G +7V7dVmZgQHF4mTKtU8Wtz8xppJAtzf84cgU88T/mHmDRdq8eLadnF718eH0+FSdBEgh J77CNZDPzhCUIjhI6VeQ9Iy16MWWMg6V2/0jR+qrY8XtHtpDSyV2tQN02VDqn6KMbXpz zA6g== 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=H7TWmeXgdS+tl3ZNVJsEECbo5Ci2DxKVW5PpDH5OFkzJ53x+w0z6AUSn3Pks4vhzNr I9tdvT8iZvABF1aErW/KmEocsYS9D6pjq9eWjSxtm1oPKoW0YFYC/7r2/iSPSAfK71XA twVlCoVadVIXKer/iEh1yR8TgZpJRMcBoKCC8atRe6c3V2ZcLM9LmjkH/I4Ia+XIJwz9 lnTn5HxHvbOFstx5jGKnL96tCXHdalHNa6pF0ZqwLG9HpvcdQCbNxJ254flWtpqDL/hy HSbs4x3a7c8oh2AxzESjCpx9xEAr1+WMMXh2602sCc7OieHq2C8OlACXxrEzQphJ7hV7 SqnQ== X-Gm-Message-State: AOAM530UULg1hp+QPjUhm1SehBjZzJ3Mypq10iH9PIa9eNQSrpXbboj+ ixBiVXubkVVNN58JdhfFKqhxeVON3a8= X-Google-Smtp-Source: ABdhPJxqs0JyaSseGj5DRM4nxHUJcekTqfU/KVjrdG+jhl10pGrRSeU8IWe8xRfkiSikDGcbRcaDRg== X-Received: by 2002:ac8:36bb:: with SMTP id a56mr53022284qtc.201.1594101908397; Mon, 06 Jul 2020 23:05:08 -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 k197sm23446778qke.133.2020.07.06.23.05.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Jul 2020 23:05:07 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Eric Sunshine , Junio C Hamano Subject: [RESEND PATCH v2 5/5] test-lib-functions: restrict test_must_fail usage Date: Tue, 7 Jul 2020 02:04:38 -0400 Message-Id: <3ebbda6c57005967b718d834aed7e3eaf00d18b4.1594101831.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