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: AS53758 23.128.96.0/24 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,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by dcvr.yhbt.net (Postfix) with ESMTP id 462C31F5AE for ; Wed, 21 Apr 2021 23:32:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243950AbhDUXdU (ORCPT ); Wed, 21 Apr 2021 19:33:20 -0400 Received: from pb-smtp21.pobox.com ([173.228.157.53]:55027 "EHLO pb-smtp21.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234681AbhDUXdT (ORCPT ); Wed, 21 Apr 2021 19:33:19 -0400 Received: from pb-smtp21.pobox.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 31586121E3D; Wed, 21 Apr 2021 19:32:46 -0400 (EDT) (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=j2m/nO7wqji8Wllly+wDKhFajV0=; b=Bxhda1 ne0Y5uC86v3oPyCQlMYcUxzQmxjix96EH/Sq3sCm7Q8cekH4/+5xcTWMKaSSvcs9 oN7O7uG9QFy0mEIhqPpBsaw97uJj9aY7hPrreug7eGb/1ICtYN4xqSsMaTLYCUM2 BAe0AthaZ9KlnMVms04ImUoYc6IW01haKtCuI= 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=QzluNOeIS4uLySWeOAr6kBq52CIerFqJ wKHyKLf8eMzKCpzNMPjUj9H0KsIuIIZT+LFmDEjihmZT/KdkjqJj7Hab8QsX5YI3 pgwYPNFzceUL9q8VBk+o5KAMvbe2P2xoCNqwMqPRZN5FjyZcdKNBI9uY0gkYW1+T ianVQATIF04= Received: from pb-smtp21.sea.icgroup.com (unknown [127.0.0.1]) by pb-smtp21.pobox.com (Postfix) with ESMTP id 29BDB121E3C; Wed, 21 Apr 2021 19:32:46 -0400 (EDT) (envelope-from junio@pobox.com) Received: from pobox.com (unknown [34.74.119.39]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pb-smtp21.pobox.com (Postfix) with ESMTPSA id 3FABE121E3B; Wed, 21 Apr 2021 19:32:42 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Eric Sunshine Cc: =?utf-8?B?xJBvw6BuIFRy4bqnbiBDw7RuZw==?= Danh , Git List Subject: Re: [PATCH 2/2] t6402: check exit status of ls-files References: <20210421104102.3409-1-congdanhqx@gmail.com> <20210421104102.3409-2-congdanhqx@gmail.com> Date: Wed, 21 Apr 2021 16:32:40 -0700 In-Reply-To: (Eric Sunshine's message of "Wed, 21 Apr 2021 13:32:32 -0400") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: DE296B30-A2F9-11EB-8013-D609E328BF65-77302942!pb-smtp21.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Eric Sunshine writes: > On Wed, Apr 21, 2021 at 12:55 PM Eric Sunshine wrote: >> count_ls_files 5 -s && >> count_ls_files 3 -u && >> count_ls_files 1 -u one~HEAD && >> ... >> >> The nice thing about having a helper function is that it can clean up >> after itself by not leaving a new file lying around, thus you wouldn't >> have to make adjustments to the expected number of untracked files (as >> mentioned in the commit message). If this is the sort of thing which >> comes up often enough (if there are more such cases beyond the two >> scripts you changed in this series), then it might make sense to >> promote the helper function to test-lib-functions.sh. > > The frequency with which this idiom crops up with commands beyond > git-ls-files suggests the more general solution of supporting it > directly in test-lib-functions.sh for any command. For instance: > > test_cmd_line_count = 3 git ls-files -u && > > Or, perhaps, a new mode of test_line_count(): > > test_line_count = 3 -c git ls-files -u && That looks nice on paper, but may be going too far. We may want to count the lines in the error message, or we may want to count the lines after filtering the output with pipe. A test file that is dedicated to test ls-files with a file local helper "count_ls_files" smells like a better place to stop, at least to me.