From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-4.2 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 0D87E2098A for ; Tue, 11 Oct 2016 10:18:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753224AbcJKKRx (ORCPT ); Tue, 11 Oct 2016 06:17:53 -0400 Received: from mout.web.de ([212.227.15.4]:58093 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752798AbcJKKRw (ORCPT ); Tue, 11 Oct 2016 06:17:52 -0400 Received: from localhost ([195.252.60.88]) by smtp.web.de (mrweb002) with ESMTPSA (Nemesis) id 0LfAfQ-1b56mK3GVE-00oqNU; Tue, 11 Oct 2016 12:09:48 +0200 Date: Tue, 11 Oct 2016 10:09:46 +0000 From: Torsten =?iso-8859-1?Q?B=F6gershausen?= To: Lars Schneider Cc: Junio C Hamano , git , Jakub =?utf-8?B?TmFyxJlic2tp?= , peff@peff.net Subject: Re: [PATCH v10 13/14] convert: add filter..process option Message-ID: <20161011100946.GA13745@tb-raspi> References: <20161008112530.15506-1-larsxschneider@gmail.com> <20161008112530.15506-14-larsxschneider@gmail.com> <02E73D87-B036-40CA-AF54-F93415A028BC@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <02E73D87-B036-40CA-AF54-F93415A028BC@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Provags-ID: V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n4= Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org On Tue, Oct 11, 2016 at 10:11:22AM +0200, Lars Schneider wrote: > > > On 10 Oct 2016, at 21:58, Junio C Hamano wrote: > > > > larsxschneider@gmail.com writes: > > > > [...] > >> +# Count unique lines except clean invocations in two files and compare > >> +# them. Clean invocations are not counted because their number can vary. > >> +# c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ > >> +test_cmp_count_except_clean () { > >> + for FILE in $@ > >> + do > >> + sort $FILE | uniq -c | sed "s/^[ ]*//" | > >> + sed "s/^\([0-9]\) IN: clean/x IN: clean/" >$FILE.tmp > >> + cat $FILE.tmp >$FILE > >> + done && > >> + test_cmp $@ > >> +} > > > > Why do you even _care_ about the number of invocations? While I > > told you why "clean" could be called multiple times under racy Git > > as an example, that was not meant to be an exhaustive example. I > > wouldn't be surprised if we needed to run smudge twice, for example, > > in some weirdly racy cases in the future. > > > > Can we just have the correctness (i.e. "we expect that the working > > tree file gets this as the result of checking it out, and we made > > sure that is the case") test without getting into such an > > implementation detail? > > My goal is to check that clean/smudge is invoked at least once. I could > just run `uniq` to achieve that but then all other filter commands could > happen multiple times and the test would not detect that. > > I also prefer to check the filter commands to ensure the filter is > working as expected (e.g. no multiple start ups etc) in addition to > checking the working tree. > > Would the patch below work for you? If yes, then please squash it into > "convert: add filter..process option". > > Thank you, > Lars > > > > diff --git a/t/t0021-conversion.sh b/t/t0021-conversion.sh > index 9f892c0..714f706 100755 > --- a/t/t0021-conversion.sh > +++ b/t/t0021-conversion.sh > @@ -31,38 +31,33 @@ filter_git () { > rm -f git-stderr.log > } > > -# Count unique lines in two files and compare them. > -test_cmp_count () { > - for FILE in $@ > - do > - sort $FILE | uniq -c | sed "s/^[ ]*//" >$FILE.tmp > - cat $FILE.tmp >$FILE > - done && > - test_cmp $@ > -} > - > -# Count unique lines except clean invocations in two files and compare > -# them. Clean invocations are not counted because their number can vary. > +# Compare two files and ensure that `clean` and `smudge` respectively are > +# called at least once if specified in the `expect` file. The actual > +# invocation count is not relevant because their number can vary. > # c.f. http://public-inbox.org/git/xmqqshv18i8i.fsf@gitster.mtv.corp.google.com/ > -test_cmp_count_except_clean () { > - for FILE in $@ > +test_cmp_count () { > + expect=$1 actual=$2 That could be expect="$1" actual="$2" > + for FILE in "$expect" "$actual" > do > + sort "$FILE" | uniq -c | sed "s/^[ ]*//" | > + sed "s/^\([0-9]\) IN: clean/x IN: clean/" | > + sed "s/^\([0-9]\) IN: smudge/x IN: smudge/" >"$FILE.tmp" && > + cat "$FILE.tmp" >"$FILE" How about cp "$FILE.tmp" "$FILE"