From patchwork Sat Jun 12 04:27:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= X-Patchwork-Id: 12316857 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 BE6FBC48BCF for ; Sat, 12 Jun 2021 04:29:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 93D03611CD for ; Sat, 12 Jun 2021 04:29:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230348AbhFLEbZ (ORCPT ); Sat, 12 Jun 2021 00:31:25 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:36395 "EHLO mail-pl1-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbhFLEbZ (ORCPT ); Sat, 12 Jun 2021 00:31:25 -0400 Received: by mail-pl1-f172.google.com with SMTP id x10so3817061plg.3 for ; Fri, 11 Jun 2021 21:29:11 -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=Fx196AKQvESKTDR5aAqf0/u0GE+KOcQVTvlEC0J9Wrs=; b=FuHkxVFYsiBrdSsuzxG45fJXhlwXyI0+0FbNqZsdwSklw1W9lyAmZct7hVCkyD958q rSNfv7Ut0FaZ7Y5fm7x2J07wTF5dZ3KcRp13Mek8K83DBtiIobEI5GKZqMsTf1aAhxRz FCyf5a2SaGby0lZz6arGD20nUT+KwJDnvXTEjcplvHnaYA1+erJHgGtYtERMqCnH01sq PAMD6eFtK5tEfO+yjMQsymrL2CjbeOjMkEydpa7p/n9mP56EsYAtRx8OHXnxPwVHdyjV eG2NF5V+xLqK2Y5LgVTppEcdi50jpx9qBPPfBahhh0cYC0yKjTNQFX26rxeSthi/p7n8 dbbg== 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=Fx196AKQvESKTDR5aAqf0/u0GE+KOcQVTvlEC0J9Wrs=; b=F1lcCoYV5TZ0bu84SB41dP6h4XLjnJwyWqC13IiYnGDmejOtedZRI+TQDtLb++Z9r0 UVmjiSjCB6fVeGbkHgxUc45YpMQ8pZFYwGL0oBzlm/RrItc/IsPcJ1oVB5jTFlznT5Tm GspqdpFGQ3IvUFNWuSBtQWGaWtO9IPjshvAoESxQgWvZGm9TlbTFGDWxGsRqErHpzkTO 4eO8Wy7sfsPseLLlNZANli/d4GgDv8Lt8cY2Ha8oWi49ZPDznJeypHVcbn5JpCMYWCe9 R3gIBvaFhxFaWNDhh07WZhUGhs+yLTDSNukOlhh6WJNnn0xcwLAfeHa+ly0rwf+0/2/Y 4arw== X-Gm-Message-State: AOAM533PMlEOKwWiaY4/vevbXU51WmktgXJ78t4DEmyNdhXvCOHHfTcE S7oN4aJF9uOVr35tZ0tSTqXsDnKrx5kfyg== X-Google-Smtp-Source: ABdhPJy+ZzKW5ihUjnjxAEvii9Ml2JjT0Khdr8hXUQ0houcWvgqrnJwzL7dw/w2tFzTGCSigFs/gFw== X-Received: by 2002:a17:90b:d95:: with SMTP id bg21mr7601965pjb.115.1623472091532; Fri, 11 Jun 2021 21:28:11 -0700 (PDT) Received: from athena.localdomain ([2402:800:63b8:97c0:59aa:7727:6cb5:cccf]) by smtp.gmail.com with ESMTPSA id w19sm11272539pjg.48.2021.06.11.21.28.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 21:28:11 -0700 (PDT) From: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= To: git@vger.kernel.org Cc: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Junio C Hamano Subject: [PATCH 1/4] test-lib-functions: introduce test_line_count_cmd Date: Sat, 12 Jun 2021 11:27:52 +0700 Message-Id: <20210612042755.28342-2-congdanhqx@gmail.com> X-Mailer: git-send-email 2.32.0.278.gd42b80f139 In-Reply-To: <20210612042755.28342-1-congdanhqx@gmail.com> References: <20210612042755.28342-1-congdanhqx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In Git project, we have multiple occasions that requires checking number of lines of text in stdout and/or stderr of a command. One of such example is t6400, which checks number of files in various states. Some of those commands are Git command, and we would like to check their exit status. In some of those checks, we pipe the stdout of those commands to "wc -l" to check for line count, thus loosing the exit status. Introduce a helper function to check for number of lines in stdout and stderr from those commands. This helper will create 2 temporary files in process, thus it may affect output of some checks. Signed-off-by: Đoàn Trần Công Danh Signed-off-by: Đoàn Trần Công Danh --- Notes: Theoretically, we could avoid those temporary files by this shenanigan: ! ( test $( ( test $( ( "$@" || echo "'$*' run into failure" >&3) | wc -l ) "$out_ops" "$out_val" || echo "stdout: !$outop $outval '$*'" >&3 ) 2>&1 | wc -l ) "$errop" "$errval" || echo "stderr: !$errop $errval '$*'" >&3 ) 3>&1 | grep . However, it looks too complicated. t/test-lib-functions.sh | 64 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index b823c14027..85bb31ea4c 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -817,6 +817,70 @@ test_line_count () { fi } +# test_line_count_cmd checks the number of lines of captured stdout and/or +# stderr of a command. +# +# NOTE: this helper function will create 2 temporary files named: +# * test_line_count_cmd_.out; and +# * test_line_count_cmd_.err +# +# And this helper function will remove those 2 files if the check is succeed. +# In case of failure, those files will be preserved. +test_line_count_cmd () { + local outop outval + local errop errval + + while test $# -ge 3 + do + case "$1" in + --out) + outop="$2" + outval="$3" + ;; + --err) + errop="$2" + errval="$3" + ;; + *) + break + ;; + esac + shift 3 + done && + if test $# = 0 || + { test "x$1" = "x!" && test $# = 1 ; } + then + BUG "test_line_count_cmd: no command to be run" + fi && + if test -z "$outop$errop" + then + BUG "test_line_count_cmd: check which stream?" + fi && + + if test "x$1" = "x!" + then + shift && + if "$@" >test_line_count_cmd_.out 2>test_line_count_cmd_.err + then + echo "error: '$@' succeed!" + return 1 + fi + elif ! "$@" >test_line_count_cmd_.out 2>test_line_count_cmd_.err + then + echo "error: '$@' run into failure!" + return 1 + fi && + if test -n "$outop" + then + test_line_count "$outop" "$outval" test_line_count_cmd_.out + fi && + if test -n "$errop" + then + test_line_count "$errop" "$errval" test_line_count_cmd_.err + fi && + rm -f test_line_count_cmd_.out test_line_count_cmd_.err +} + test_file_size () { test "$#" -ne 1 && BUG "1 param" test-tool path-utils file-size "$1" From patchwork Sat Jun 12 04:27:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= X-Patchwork-Id: 12316853 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 4C8A0C48BE5 for ; Sat, 12 Jun 2021 04:28:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2EAE06120D for ; Sat, 12 Jun 2021 04:28:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229985AbhFLEaU (ORCPT ); Sat, 12 Jun 2021 00:30:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229446AbhFLEaT (ORCPT ); Sat, 12 Jun 2021 00:30:19 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF050C061574 for ; Fri, 11 Jun 2021 21:28:14 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id v12so3805507plo.10 for ; Fri, 11 Jun 2021 21:28:14 -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=E0As/PiTgAKXG1QBmBfO8WmAAJV6/5IlMyzY0z71GFE=; b=Emr9WjU17MqK18YWevP1KsweUagn6oTEUMtcbb2jq7JtdbGGWihED0NALXtaAjplyf qsr7GWG60pa7eVNnBXQpfSYvCWRu0kmguxYvSwTYGvoK8m/msm6fIdTsQktn482X/Azo YTNLiD5k6NjuZxxfD8QgbzVSoh1eA1YBYGmLlwutrpH7DksWjZjJOEbA/038EnaGJlRP R8q58oegNewLGYzZDNkvj9l7hpRtuiiG1M4U+Cg9qxKaQW3JkGKT4ga0P4D6E+mLgYlt RMJXSTn665xHycuNJ6XdWjFfd/Jg2HkNCWcLAa9MFMr6FC/yL3uFY0T5MFr6Pzlv8tOO WaZQ== 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=E0As/PiTgAKXG1QBmBfO8WmAAJV6/5IlMyzY0z71GFE=; b=PEAWcU9BxmwrSOm4ufUBIw030XOW+1xrq1Ruwrt7rPq9NbPAFApSWAhwrBqNbwi/Fb M64dA4giM73KKyThOuXBQ+4IaSIEjZfH4kJYh2l4u3U3PE7kPSr+CHFPo5IGugodbm31 t59slHQspHPJszeyxA/fTS9y87OfBFQ51ie8rM7uzqkcCYi7xx9CH5o7DWkHvKbib3nt HLd1AlLRdym90DTNnPMcsUQIvfgidccSw5yQn0ywWwqBHDYKp2pSb8WOrseJR51Yf6es UHAnIQB4nJVJf/suE8sNpidIFa/2Rauflepy0xbJ5RYHWITK4WJTlawfrbUEjctbBFOt r6IA== X-Gm-Message-State: AOAM531nMvXU0+PS1VKvOTUdgwsSOyWy4XnhnPb+1rFp0jXKz9Q9XzfH 70gMcVdJwNfMwl/hn9rAjhpoa1eHS86FAw== X-Google-Smtp-Source: ABdhPJwstd8G8bj68sNgSB0Uiar/cFSKchqkQ7lT3XCqDVwicXhkyqctBKOF8X1IXNZ12QQZFxnmKQ== X-Received: by 2002:a17:90a:e006:: with SMTP id u6mr7708043pjy.132.1623472093794; Fri, 11 Jun 2021 21:28:13 -0700 (PDT) Received: from athena.localdomain ([2402:800:63b8:97c0:59aa:7727:6cb5:cccf]) by smtp.gmail.com with ESMTPSA id w19sm11272539pjg.48.2021.06.11.21.28.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 21:28:13 -0700 (PDT) From: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= To: git@vger.kernel.org Cc: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Junio C Hamano Subject: [PATCH 2/4] t6402: use find(1) builtin to filter instead of grep Date: Sat, 12 Jun 2021 11:27:53 +0700 Message-Id: <20210612042755.28342-3-congdanhqx@gmail.com> X-Mailer: git-send-email 2.32.0.278.gd42b80f139 In-Reply-To: <20210612042755.28342-1-congdanhqx@gmail.com> References: <20210612042755.28342-1-congdanhqx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org find(1) has a builtin (-prune) to filter its output, save a bit of time for invoking grep(1). In addition, in a later change, we will try to use test_line_count_cmd to count number of lines in stdout and/or stderr of a command, due to limitation of current implementation, it can handle pipe. Let's replace grep(1)'s usage with find(1) builtin filter. Signed-off-by: Đoàn Trần Công Danh --- t/t6402-merge-rename.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh index 425dad97d5..5d76cd6414 100755 --- a/t/t6402-merge-rename.sh +++ b/t/t6402-merge-rename.sh @@ -546,7 +546,7 @@ then test_must_fail git diff --quiet && - test 3 -eq $(find . | grep -v .git | wc -l) && + test 3 -eq $(find . -name .git -prune -o -print | wc -l) && test_path_is_file one && test_path_is_file two && @@ -565,7 +565,7 @@ else test_must_fail git diff --quiet && - test 4 -eq $(find . | grep -v .git | wc -l) && + test 4 -eq $(find . -name .git -prune -o -print | wc -l) && test_path_is_dir one && test_path_is_file one~rename-two && @@ -593,7 +593,7 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta test_must_fail git diff --quiet && - test 3 -eq $(find . | grep -v .git | wc -l) && + test 3 -eq $(find . -name .git -prune -o -print | wc -l) && test_path_is_file one && test_path_is_file two && From patchwork Sat Jun 12 04:27:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= X-Patchwork-Id: 12316851 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 073A6C48BCF for ; Sat, 12 Jun 2021 04:28:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E0568611CB for ; Sat, 12 Jun 2021 04:28:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230125AbhFLEaQ (ORCPT ); Sat, 12 Jun 2021 00:30:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40370 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230348AbhFLEaP (ORCPT ); Sat, 12 Jun 2021 00:30:15 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 58691C061767 for ; Fri, 11 Jun 2021 21:28:16 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso7104458pjp.2 for ; Fri, 11 Jun 2021 21:28:16 -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=fOPWrx792qnVTqGh1fO0w44RLC5KmcDTCvJubsoU5s0=; b=TwcdMcu6qAiaYgLrxJwboclCeN7s+7iKZKhREUTvsRTj9QW0YYCSVBra5PHDi8dK/8 jW6uEcIK6yIXk6THVHijbjKQK9Q8RmQrCw3Wh1zUUFRf3K/FCD+1xYA1t82GqXSoQAnF Ej98EhaJR6AJi7+IGnrbwru15XGnTvNHMehcI+zHNp2VxqafH+B3HDL2l85l1P3tCqEL al6C+xNy4HWtXqvOlmq1p1jgSCZ4v0YVeJSGZKfI2Mxx1paGng0uWjNTHWu0kB83TC3E pO/w6z/Yd0hafQzhQ4cNAgKkFmBKGU8y7pPndsqC7DyZt+KSBOWzH/uM4OO8ugpsNk5n SVCw== 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=fOPWrx792qnVTqGh1fO0w44RLC5KmcDTCvJubsoU5s0=; b=UZp9CRV4gZMUem2zGCDXixW9NwYh1c6VsNyPckyHoRddxe9/jRb2nroyvmPCyIogoi oJd3CXr+7j9PuWhzxfz1Os4PxjimcFvDZdFJpTIc4NUXLB0iu/ZnwB2/4gNoin1QnM6y lu9rXzZgDf6og/O77CRxSTJUtKM6NgrO3hY2AwQUuZvO0gliEAz4whktg6WakD/hBdJ0 JYs+POMWyzqT/DXbmvPIjFDHdoiTrcPTNeNgHFAeuT/Ks2s3LjnfBf70YV+jdjCtxhZL qv/fr0PxXODeNq2obYa29FdvZAO2l3MvZkiJvvSI7PRNexN4f1VJKXRdGeaUkEX10r/j YOGg== X-Gm-Message-State: AOAM530BtmYu26UJpMZwYH/Y5U9Au7JTVs6D3wOrLDDMl4YPNaqLxiBh s6vTfkVHXsCraZh2A3pR4OMOmkPc3OflMg== X-Google-Smtp-Source: ABdhPJwQ1ULDCKNI3Yug13rhOCwv/jjBj50dZUP+S3gK1CfNSHPbnbxXf5TR3i3dtoLosYdfdooR5w== X-Received: by 2002:a17:90a:d082:: with SMTP id k2mr9503118pju.15.1623472095772; Fri, 11 Jun 2021 21:28:15 -0700 (PDT) Received: from athena.localdomain ([2402:800:63b8:97c0:59aa:7727:6cb5:cccf]) by smtp.gmail.com with ESMTPSA id w19sm11272539pjg.48.2021.06.11.21.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 21:28:15 -0700 (PDT) From: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= To: git@vger.kernel.org Cc: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Junio C Hamano Subject: [PATCH 3/4] t6400: use test_line_count_cmd to count # of lines in stdout Date: Sat, 12 Jun 2021 11:27:54 +0700 Message-Id: <20210612042755.28342-4-congdanhqx@gmail.com> X-Mailer: git-send-email 2.32.0.278.gd42b80f139 In-Reply-To: <20210612042755.28342-1-congdanhqx@gmail.com> References: <20210612042755.28342-1-congdanhqx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Đoàn Trần Công Danh --- t/t6400-merge-df.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/t/t6400-merge-df.sh b/t/t6400-merge-df.sh index 38700d29b5..9d7b9354c5 100755 --- a/t/t6400-merge-df.sh +++ b/t/t6400-merge-df.sh @@ -82,13 +82,13 @@ test_expect_success 'modify/delete + directory/file conflict' ' git checkout delete^0 && test_must_fail git merge modify && - test 5 -eq $(git ls-files -s | wc -l) && - test 4 -eq $(git ls-files -u | wc -l) && + test_line_count_cmd --out = 5 git ls-files -s && + test_line_count_cmd --out = 4 git ls-files -u && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 0 -eq $(git ls-files -o | wc -l) + test_line_count_cmd --out = 2 git ls-files -o else - test 1 -eq $(git ls-files -o | wc -l) + test_line_count_cmd --out = 3 git ls-files -o fi && test_path_is_file letters/file && @@ -103,13 +103,13 @@ test_expect_success 'modify/delete + directory/file conflict; other way' ' test_must_fail git merge delete && - test 5 -eq $(git ls-files -s | wc -l) && - test 4 -eq $(git ls-files -u | wc -l) && + test_line_count_cmd --out = 5 git ls-files -s && + test_line_count_cmd --out = 4 git ls-files -u && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 0 -eq $(git ls-files -o | wc -l) + test_line_count_cmd --out = 2 git ls-files -o else - test 1 -eq $(git ls-files -o | wc -l) + test_line_count_cmd --out = 3 git ls-files -o fi && test_path_is_file letters/file && From patchwork Sat Jun 12 04:27:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= X-Patchwork-Id: 12316855 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 4B8ADC48BE5 for ; Sat, 12 Jun 2021 04:28:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CF6F611CB for ; Sat, 12 Jun 2021 04:28:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230411AbhFLEa3 (ORCPT ); Sat, 12 Jun 2021 00:30:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40378 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230141AbhFLEa1 (ORCPT ); Sat, 12 Jun 2021 00:30:27 -0400 Received: from mail-pj1-x102f.google.com (mail-pj1-x102f.google.com [IPv6:2607:f8b0:4864:20::102f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86E85C061767 for ; Fri, 11 Jun 2021 21:28:18 -0700 (PDT) Received: by mail-pj1-x102f.google.com with SMTP id g4so6789406pjk.0 for ; Fri, 11 Jun 2021 21:28:18 -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=n7TLV0sMEPXCUI8gJcQL9AAaePagmi5696XHsHr8qKU=; b=LmNnAVFY/7Sx32GMIvN7CNDhTrn+zaqXk9LiLqt4L2kSCnhEzlgaZL9KiKOrhDc7xQ aSkJdligedcg1HWpU0Plt/NzjA2cyX3PWq45HymxR61248idSp3dXvLJy1y9vPLRsUiV 6kuXr/yF8+v7JzTGol0ZrwSuR3wlGv+tk1ybB50oXtdGsGLgi0cQ3wkAGoxyeWDn+1Co 2JR0AAQQFH286y5fx3N1o4GcUmQ90fEApJ7URoTaVKqf5OVaZ5PvosWZaB7BLWzGiCHm 27dw/OIvlOs4hwR9UUN7wSl5ch5xsx7mSF2pUcqKWckAPbtrkA4e06PdrjabhwrzzapF p3pw== 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=n7TLV0sMEPXCUI8gJcQL9AAaePagmi5696XHsHr8qKU=; b=gJ6zpbjJYS4hfAe3OXT0MvcK0iZBijF5Eu4qqlYD0bjK+5kDBWfQ3Ktnq93QDEzEHY gvYx8bqQk1bZ2r0Mc7aJrc+B3vtbssFediao5BMnJzZFRDcTdCYzoQvbx6kQ28oVr0Wv Oz780BgeGW8Y5lePwpv1c7kTtowa946GtFH6ZVcrB+/hiGg4qmzyfT4WD78e1iGz3hus gbHKqdmR8OYSEwQqyiFNAra0LqdSm1RlsVt/W8T+frmTOFkCXw5Jex7XXSpxd6RuTVPF 10vXcUkFhpl1mP+eXnT9HPeoRzbGV5QqkpOn5BEaymBst+BRu6ehRL7KvT8D6WyyQgQT g3ZQ== X-Gm-Message-State: AOAM533mTN0vbS4lRvr7X+sipubnyQ+GU0rxGQSkPscjgCI1burFDNUK YLHc6eAUd0sjsRGDK8XMmck7oJkoib9ytQ== X-Google-Smtp-Source: ABdhPJxB5Al1mAl5v/20ho0er16nfwVtcOLiFcBwuWMbT2yt7xOom+K0OM7vVh7FMG1E19QasKqy/A== X-Received: by 2002:a17:90a:ce02:: with SMTP id f2mr7905232pju.162.1623472097890; Fri, 11 Jun 2021 21:28:17 -0700 (PDT) Received: from athena.localdomain ([2402:800:63b8:97c0:59aa:7727:6cb5:cccf]) by smtp.gmail.com with ESMTPSA id w19sm11272539pjg.48.2021.06.11.21.28.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Jun 2021 21:28:17 -0700 (PDT) From: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= To: git@vger.kernel.org Cc: =?utf-8?b?xJBvw6BuIFRy4bqnbiBDw7RuZyBEYW5o?= , Eric Sunshine , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Junio C Hamano Subject: [PATCH 4/4] t6402: use test_line_count_cmd to count # of lines in stdout Date: Sat, 12 Jun 2021 11:27:55 +0700 Message-Id: <20210612042755.28342-5-congdanhqx@gmail.com> X-Mailer: git-send-email 2.32.0.278.gd42b80f139 In-Reply-To: <20210612042755.28342-1-congdanhqx@gmail.com> References: <20210612042755.28342-1-congdanhqx@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Đoàn Trần Công Danh --- t/t6402-merge-rename.sh | 126 +++++++++++++++++++--------------------- 1 file changed, 59 insertions(+), 67 deletions(-) diff --git a/t/t6402-merge-rename.sh b/t/t6402-merge-rename.sh index 5d76cd6414..81502dba84 100755 --- a/t/t6402-merge-rename.sh +++ b/t/t6402-merge-rename.sh @@ -105,10 +105,8 @@ test_expect_success 'pull renaming branch into unrenaming one' \ git show-branch && test_expect_code 1 git pull . white && git ls-files -s && - git ls-files -u B >b.stages && - test_line_count = 3 b.stages && - git ls-files -s N >n.stages && - test_line_count = 1 n.stages && + test_line_count_cmd --out = 3 git ls-files -u B && + test_line_count_cmd --out = 1 git ls-files -s N && sed -ne "/^g/{ p q @@ -122,10 +120,8 @@ test_expect_success 'pull renaming branch into another renaming one' \ git reset --hard && git checkout red && test_expect_code 1 git pull . white && - git ls-files -u B >b.stages && - test_line_count = 3 b.stages && - git ls-files -s N >n.stages && - test_line_count = 1 n.stages && + test_line_count_cmd --out = 3 git ls-files -u B && + test_line_count_cmd --out = 1 git ls-files -s N && sed -ne "/^g/{ p q @@ -138,10 +134,8 @@ test_expect_success 'pull unrenaming branch into renaming one' \ git reset --hard && git show-branch && test_expect_code 1 git pull . main && - git ls-files -u B >b.stages && - test_line_count = 3 b.stages && - git ls-files -s N >n.stages && - test_line_count = 1 n.stages && + test_line_count_cmd --out = 3 git ls-files -u B && + test_line_count_cmd --out = 1 git ls-files -s N && sed -ne "/^g/{ p q @@ -154,14 +148,10 @@ test_expect_success 'pull conflicting renames' \ git reset --hard && git show-branch && test_expect_code 1 git pull . blue && - git ls-files -u A >a.stages && - test_line_count = 1 a.stages && - git ls-files -u B >b.stages && - test_line_count = 1 b.stages && - git ls-files -u C >c.stages && - test_line_count = 1 c.stages && - git ls-files -s N >n.stages && - test_line_count = 1 n.stages && + test_line_count_cmd --out = 1 git ls-files -u A && + test_line_count_cmd --out = 1 git ls-files -u B && + test_line_count_cmd --out = 1 git ls-files -u C && + test_line_count_cmd --out = 1 git ls-files -s N && sed -ne "/^g/{ p q @@ -330,8 +320,8 @@ test_expect_success 'Rename+D/F conflict; renamed file merges but dir in way' ' test_i18ngrep "Adding as dir~HEAD instead" output fi && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 2 git ls-files -u dir/file-in-the-way && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -357,8 +347,8 @@ test_expect_success 'Same as previous, but merged other way' ' test_i18ngrep "Adding as dir~renamed-file-has-no-conflicts instead" output fi && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 2 git ls-files -u dir/file-in-the-way && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -374,8 +364,8 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge, dir not in git checkout -q renamed-file-has-conflicts^0 && test_must_fail git merge --strategy=recursive dir-not-in-way && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 3 -eq "$(git ls-files -u dir | wc -l)" && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 3 git ls-files -u dir && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -409,14 +399,15 @@ test_expect_success 'Rename+D/F conflict; renamed file cannot merge and dir in t git checkout -q renamed-file-has-conflicts^0 && test_must_fail git merge --strategy=recursive dir-in-way && - test 5 -eq "$(git ls-files -u | wc -l)" && + test_line_count_cmd --out = 5 git ls-files -u && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 3 -eq "$(git ls-files -u dir~HEAD | wc -l)" + test_line_count_cmd --out = 3 git ls-files -u dir~HEAD else - test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" + git ls-files -u dir >out && + test_line_count_cmd --out = 3 grep -v file-in-the-way out fi && - test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test_line_count_cmd --out = 2 git ls-files -u dir/file-in-the-way && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -432,14 +423,15 @@ test_expect_success 'Same as previous, but merged other way' ' git checkout -q dir-in-way^0 && test_must_fail git merge --strategy=recursive renamed-file-has-conflicts && - test 5 -eq "$(git ls-files -u | wc -l)" && + test_line_count_cmd --out = 5 git ls-files -u && if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 3 -eq "$(git ls-files -u dir~renamed-file-has-conflicts | wc -l)" + test_line_count_cmd --out = 3 git ls-files -u dir~renamed-file-has-conflicts else - test 3 -eq "$(git ls-files -u dir | grep -v file-in-the-way | wc -l)" + git ls-files -u dir >out && + test_line_count_cmd --out = 3 grep -v file-in-the-way out fi && - test 2 -eq "$(git ls-files -u dir/file-in-the-way | wc -l)" && + test_line_count_cmd --out = 2 git ls-files -u dir/file-in-the-way && test_must_fail git diff --quiet && test_must_fail git diff --cached --quiet && @@ -496,9 +488,9 @@ test_expect_success 'both rename source and destination involved in D/F conflict if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 2 -eq "$(git ls-files -u | wc -l)" + test_line_count_cmd --out = 2 git ls-files -u else - test 1 -eq "$(git ls-files -u | wc -l)" + test_line_count_cmd --out = 1 git ls-files -u fi && test_must_fail git diff --quiet && @@ -540,9 +532,9 @@ then mkdir one && test_must_fail git merge --strategy=recursive rename-two && - test 4 -eq "$(git ls-files -u | wc -l)" && - test 2 -eq "$(git ls-files -u one | wc -l)" && - test 2 -eq "$(git ls-files -u two | wc -l)" && + test_line_count_cmd --out = 4 git ls-files -u && + test_line_count_cmd --out = 2 git ls-files -u one && + test_line_count_cmd --out = 2 git ls-files -u two && test_must_fail git diff --quiet && @@ -559,9 +551,9 @@ else mkdir one && test_must_fail git merge --strategy=recursive rename-two && - test 2 -eq "$(git ls-files -u | wc -l)" && - test 1 -eq "$(git ls-files -u one | wc -l)" && - test 1 -eq "$(git ls-files -u two | wc -l)" && + test_line_count_cmd --out = 2 git ls-files -u && + test_line_count_cmd --out = 1 git ls-files -u one && + test_line_count_cmd --out = 1 git ls-files -u two && test_must_fail git diff --quiet && @@ -582,13 +574,13 @@ test_expect_success 'pair rename to parent of other (D/F conflicts) w/ clean sta if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 4 -eq "$(git ls-files -u | wc -l)" && - test 2 -eq "$(git ls-files -u one | wc -l)" && - test 2 -eq "$(git ls-files -u two | wc -l)" + test_line_count_cmd --out = 4 git ls-files -u && + test_line_count_cmd --out = 2 git ls-files -u one && + test_line_count_cmd --out = 2 git ls-files -u two else - test 2 -eq "$(git ls-files -u | wc -l)" && - test 1 -eq "$(git ls-files -u one | wc -l)" && - test 1 -eq "$(git ls-files -u two | wc -l)" + test_line_count_cmd --out = 2 git ls-files -u && + test_line_count_cmd --out = 1 git ls-files -u one && + test_line_count_cmd --out = 1 git ls-files -u two fi && test_must_fail git diff --quiet && @@ -631,19 +623,19 @@ test_expect_success 'check handling of differently renamed file with D/F conflic if test "$GIT_TEST_MERGE_ALGORITHM" = ort then - test 5 -eq "$(git ls-files -s | wc -l)" && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 1 -eq "$(git ls-files -u one~HEAD | wc -l)" && - test 1 -eq "$(git ls-files -u two~second-rename | wc -l)" && - test 1 -eq "$(git ls-files -u original | wc -l)" && - test 0 -eq "$(git ls-files -o | wc -l)" + test_line_count_cmd --out = 5 git ls-files -s && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 1 git ls-files -u one~HEAD && + test_line_count_cmd --out = 1 git ls-files -u two~second-rename && + test_line_count_cmd --out = 1 git ls-files -u original && + test_line_count_cmd --out = 2 git ls-files -o else - test 5 -eq "$(git ls-files -s | wc -l)" && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 1 -eq "$(git ls-files -u one | wc -l)" && - test 1 -eq "$(git ls-files -u two | wc -l)" && - test 1 -eq "$(git ls-files -u original | wc -l)" && - test 2 -eq "$(git ls-files -o | wc -l)" + test_line_count_cmd --out = 5 git ls-files -s && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 1 git ls-files -u one && + test_line_count_cmd --out = 1 git ls-files -u two && + test_line_count_cmd --out = 1 git ls-files -u original && + test_line_count_cmd --out = 4 git ls-files -o fi && test_path_is_file one/file && @@ -679,11 +671,11 @@ test_expect_success 'check handling of differently renamed file with D/F conflic git checkout -q first-rename-redo^0 && test_must_fail git merge --strategy=recursive second-rename-redo && - test 3 -eq "$(git ls-files -u | wc -l)" && - test 1 -eq "$(git ls-files -u one | wc -l)" && - test 1 -eq "$(git ls-files -u two | wc -l)" && - test 1 -eq "$(git ls-files -u original | wc -l)" && - test 0 -eq "$(git ls-files -o | wc -l)" && + test_line_count_cmd --out = 3 git ls-files -u && + test_line_count_cmd --out = 1 git ls-files -u one && + test_line_count_cmd --out = 1 git ls-files -u two && + test_line_count_cmd --out = 1 git ls-files -u original && + test_line_count_cmd --out = 2 git ls-files -o && test_path_is_file one && test_path_is_file two && @@ -861,8 +853,8 @@ test_expect_success 'setup merge of rename + small change' ' test_expect_success 'merge rename + small change' ' git merge rename_branch && - test 1 -eq $(git ls-files -s | wc -l) && - test 0 -eq $(git ls-files -o | wc -l) && + test_line_count_cmd --out = 1 git ls-files -s && + test_line_count_cmd --out = 2 git ls-files -o && test $(git rev-parse HEAD:renamed_file) = $(git rev-parse HEAD~1:file) '