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-Status: No, score=-3.9 required=3.0 tests=AWL,BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,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 1970F1F4B4 for ; Fri, 16 Oct 2020 23:14:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2407447AbgJPXOg (ORCPT ); Fri, 16 Oct 2020 19:14:36 -0400 Received: from pb-smtp2.pobox.com ([64.147.108.71]:61314 "EHLO pb-smtp2.pobox.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2409430AbgJPXOf (ORCPT ); Fri, 16 Oct 2020 19:14:35 -0400 Received: from pb-smtp2.pobox.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id B860282EDF; Fri, 16 Oct 2020 19:14:32 -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=avbvziTz7K7ej9aaG0uwdsvwgTw=; b=qe6EeD vLnlczKm+W2TwAc56106yyeLNTXRv7u7Y1o6Xq0+4zDLSt/+sMSGsFFRGky7VHL2 qXVoQTL8b3wtrfbc/xXoswHmIz54aLlvjBtvlIRgCkoTd6xHZa46MtRtY3F8jwdM uUDCviJzqYNuI/rH96flv/cvB89zC7XW+3nso= 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=ZEhnCR0xQdwki3VcSILqY9vW69rSYfHq o9fk0LS7cZIP/UMe0ToglC3mYa9W4TTuFG5dM+Z3HjIqFsaNsLuiuRqVMV/QMUkB 0EIz0kCAETqq/bvBEN68B7J4ZVcSEtQi1JAVu+cKuqE8XgFBfqqW07e/gklGs1PH KOMgxB5ifV8= Received: from pb-smtp2.nyi.icgroup.com (unknown [127.0.0.1]) by pb-smtp2.pobox.com (Postfix) with ESMTP id AFD9D82EDE; Fri, 16 Oct 2020 19:14:32 -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-smtp2.pobox.com (Postfix) with ESMTPSA id 3A76682EDD; Fri, 16 Oct 2020 19:14:32 -0400 (EDT) (envelope-from junio@pobox.com) From: Junio C Hamano To: Eric Sunshine Cc: Jeff King , Git List , Elijah Newren , Shourya Shukla , =?utf-8?B?w4Z2YXIgQXJuZmrDtnLDsA==?= Bjarmason Subject: Re: [PATCH v2] test_cmp: diagnose incorrect arguments References: <20200809060810.31370-1-sunshine@sunshineco.com> <20200809174209.15466-1-sunshine@sunshineco.com> <20201016001704.GA2937048@coredump.intra.peff.net> Date: Fri, 16 Oct 2020 16:14:31 -0700 In-Reply-To: (Junio C. Hamano's message of "Fri, 16 Oct 2020 13:56:00 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Pobox-Relay-ID: 59369F4C-1005-11EB-9027-74DE23BA3BAF-77302942!pb-smtp2.pobox.com Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Junio C Hamano writes: > test_cmp() { > - test $# -eq 2 || BUG "test_cmp requires two arguments" > - if ! eval "$GIT_TEST_CMP" '"$@"' > - then > - test "x$1" = x- || test -e "$1" || BUG "test_cmp '$1' missing" > - test "x$2" = x- || test -e "$2" || BUG "test_cmp '$2' missing" > - return 1 > - fi > + eval "$GIT_TEST_CMP" '"$@"' > } > > # Check that the given config key has the expected value. > @@ -940,13 +934,7 @@ test_cmp_config() { > # test_cmp_bin - helper to compare binary files > > test_cmp_bin() { > - test $# -eq 2 || BUG "test_cmp_bin requires two arguments" > - if ! cmp "$@" > - then > - test "x$1" = x- || test -e "$1" || BUG "test_cmp_bin '$1' missing" > - test "x$2" = x- || test -e "$2" || BUG "test_cmp_bin '$2' missing" > - return 1 > - fi > + cmp "$@" > } Looking at this again, I think we could keep the "we should have two arguments, no more than, no less than, but exactly two". But I think those who write new tests are working to eventually make them pass, so hopefully they'll notice and investigate test_cmp that yields false anyway, I guess.