From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.0 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 449FB1F466 for ; Thu, 16 Jan 2020 21:40:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730325AbgAPVkq (ORCPT ); Thu, 16 Jan 2020 16:40:46 -0500 Received: from pb-smtp1.pobox.com ([64.147.108.70]:61059 "EHLO pb-smtp1.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730059AbgAPVkq (ORCPT ); Thu, 16 Jan 2020 16:40:46 -0500 Received: from pb-smtp1.pobox.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id C2CF5386A5; Thu, 16 Jan 2020 16:40:40 -0500 (EST) (envelope-from junio@pobox.com) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=/diPGqT773TlAVHZm0uxeEy38kc=; b=oYB/NB XDBRwgiFSEH2wv78oCoEslYP76UXB0EnmSdGpOSDTe0bZC7tIXZpjU87DLjQqNKg lH85JA0VXzjX7srdkPlLqQQ9IT870huS6qFXdGnEIKzfSneg1ZNp4XQvM1tCRkwo ynlFQEfwdRMv0Yycq/LnexL6wvKXA2Hrm+dOQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=Tz+ed7kPDehkDGJNPmGb0X52qn205h4h m0kdmBk6Mqy+Gu3ZlSW1R4JKnFYeakANkSuejHLh9526P4XarigRc8Wif9IXMjN9 vlmVHUTQxBKtKs1DKuvXwY6OCRbdRD9f1+Qo/NEXKuygEJwCxXSPXYLFFeJaZ/wt 2KutUfzcTIQ= Received: from pb-smtp1.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp1.pobox.com (Postfix) with ESMTP id BA23E386A4; Thu, 16 Jan 2020 16:40:40 -0500 (EST) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.76.80.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp1.pobox.com (Postfix) with ESMTPSA id 0F1E6386A3; Thu, 16 Jan 2020 16:40:39 -0500 (EST) (envelope-from junio@pobox.com) From: Junio C Hamano To: "Derrick Stolee via GitGitGadget" Cc: git@vger.kernel.org, me@ttaylorr.com, peff@peff.net, newren@gmail.com, Derrick Stolee Subject: Re: [PATCH 1/8] t1091: use check_files to reduce boilerplate References: <9f7791ae5ee8df9d84d25407a014fb2c63e09b38.1579029963.git.gitgitgadget@gmail.com> Date: Thu, 16 Jan 2020 13:40:38 -0800 In-Reply-To: <9f7791ae5ee8df9d84d25407a014fb2c63e09b38.1579029963.git.gitgitgadget@gmail.com> (Derrick Stolee via GitGitGadget's message of "Tue, 14 Jan 2020 19:25:55 +0000") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: D6FD9992-38A8-11EA-94A2-C28CBED8090B-77302942!pb-smtp1.pobox.com Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org "Derrick Stolee via GitGitGadget" writes: > From: Derrick Stolee > > When testing the sparse-checkout feature, we need to compare the > contents of the working-directory against some expected output. > Using here-docs was useful in the beginning, but became repetetive > as the test script grew. > > Create a check_files helper to make the tests simpler and easier > to extend. It also reduces instances of bad here-doc whitespace. > > Signed-off-by: Derrick Stolee > --- > t/t1091-sparse-checkout-builtin.sh | 215 ++++++++++------------------- > 1 file changed, 71 insertions(+), 144 deletions(-) > > diff --git a/t/t1091-sparse-checkout-builtin.sh b/t/t1091-sparse-checkout-builtin.sh > index ff7f8f7a1f..20caefe155 100755 > --- a/t/t1091-sparse-checkout-builtin.sh > +++ b/t/t1091-sparse-checkout-builtin.sh > @@ -12,6 +12,13 @@ list_files() { > (cd "$1" && printf '%s\n' *) > } > > +check_files() { > + DIR=$1 > + printf "%s\n" $2 >expect && > + list_files $DIR >actual && It is unclear if the script is being deliberate or sloppy. It turns out that not quoting $2 is deliberate (i.e. it wants to pass more than one words in $2, have them split at $IFS and show each of them on a separate line), at the same time not quoting $DIR is simply sloppy. And it is totally unnecessary to confuse readers like this. Unless you plan to extend this helper further, I think this would be much less burdensome to the readers: check_files () { list_files "$1" >actual && shift && printf "%s\n" "$@" >expect && test_cmp expect actual } This ... > test_cmp expect repo/.git/info/sparse-checkout && > - list_files repo >dir && > - cat >expect <<-EOF && > - a > - folder1 > - folder2 > - EOF > - test_cmp expect dir > + check_files repo "a folder1 folder2" ... is a kind of change that the log message advertises, which is a very nice rewrite. And ... > test_expect_success 'clone --sparse' ' > git clone --sparse repo clone && > git -C clone sparse-checkout list >actual && > - cat >expect <<-EOF && > - /* > - !/*/ > + cat >expect <<-\EOF && > + /* > + !/*/ > EOF ... this is a style-fix that is another nice rewrite but in a different category. I wonder if they should be done in separate commits. Other than that, makes sense. Thanks.