From patchwork Tue Feb 9 19:40:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 6, V2] tests: add alias to detect external diff invocation via extdiff From: Katsunori FUJIWARA X-Patchwork-Id: 13069 Message-Id: To: yuya@tcha.org Cc: mercurial-devel@mercurial-scm.org Date: Wed, 10 Feb 2016 04:40:00 +0900 At Tue, 9 Feb 2016 23:44:33 +0900, Yuya Nishihara wrote: > > On Mon, 08 Feb 2016 18:39:22 +0900, FUJIWARA Katsunori wrote: > > # HG changeset patch > > # User FUJIWARA Katsunori > > # Date 1454923758 -32400 > > # Mon Feb 08 18:29:18 2016 +0900 > > # Node ID 8bfab6803b7ef9c4e26c5834c9d2deeccc4f074b > > # Parent 2d91a08cbf07bcb0413f5de8cc880571d9522987 > > tests: add alias to detect external diff invocation via extdiff > > > > As previous patch described, direct usage of external "diff" command > > via extdiff extension isn't portable. > > > > To detect unintentional external "diff" command invocation via extdiff > > immediately, this patch adds HGRCPATH file an alias definition below, > > which shadows original "hg extdiff". > > > > [alias] > > extdiff = !echo use tests/pdiff via extdiff extension for portability > > Can't it be a check-code rule? > I think "hg extdiff" with no -p/-o will catch most of errors. If we add new check-code rule "hg( .+)* extdiff" or so, it should ignore checking "test-extdiff.t", which tests "hg extdiff" itself. To ignore it safely, is adding list "checks" a new entry like as below reasonable ? ==================== BTW, in that case, usage of extdiff in "test-extension.t" should be fully replaced by another one, too :-) > The patch 5 looks good but I've not pushed yet as you might want to fold > check-code rule into it. ---------------------------------------------------------------------- [FUJIWARA Katsunori] foozy@lares.dti.ne.jp ==================== diff --git a/contrib/check-code.py b/contrib/check-code.py --- a/contrib/check-code.py +++ b/contrib/check-code.py @@ -386,6 +386,7 @@ checks = [ ('test script', r'(.*/)?test-[^.~]*$', '', testfilters, testpats), ('c', r'.*\.[ch]$', '', cfilters, cpats), ('unified test', r'.*\.t$', '', utestfilters, utestpats), + ('unified test, r'(?!test-extdiff\.t).*\.t$', utestfilters, extdiffats), ('layering violation repo in revlog', r'mercurial/revlog\.py', '', pyfilters, inrevlogpats), ('layering violation ui in util', r'mercurial/util\.py', '', pyfilters,