Patchwork [6,of,6,V2] tests: add alias to detect external diff invocation via extdiff

login
register
mail settings
Submitter Katsunori FUJIWARA
Date Feb. 8, 2016, 9:39 a.m.
Message ID <8bfab6803b7ef9c4e26c.1454924362@juju>
Download mbox | patch
Permalink /patch/13050/
State Accepted
Headers show

Comments

Katsunori FUJIWARA - Feb. 8, 2016, 9:39 a.m.
# HG changeset patch
# User FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
# 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

"use 'sh $RUNTESTDIR/pdiff' via extdiff ...."  or so might be more
useful, but this patch avoids using '$' or so in the message, because
of test portability: shell on POSIX platform and "cmd.exe" on Windows
platform differ from each other about handling '$' prefixed string,
escaping special character, quoting, and so on.

Patch

diff --git a/tests/run-tests.py b/tests/run-tests.py
--- a/tests/run-tests.py
+++ b/tests/run-tests.py
@@ -792,6 +792,9 @@  class Test(unittest.TestCase):
         hgrc.write(b'[largefiles]\n')
         hgrc.write(b'usercache = %s\n' %
                    (os.path.join(self._testtmp, b'.cache/largefiles')))
+        hgrc.write(b'[alias]\n')
+        hgrc.write(b'extdiff = !echo %s\n' %
+                   b'use tests/pdiff via extdiff extension for portability')
 
         for opt in self._extraconfigopts:
             section, key = opt.split('.', 1)
diff --git a/tests/test-basic.t b/tests/test-basic.t
--- a/tests/test-basic.t
+++ b/tests/test-basic.t
@@ -1,6 +1,7 @@ 
 Create a repository:
 
   $ hg config
+  alias.extdiff=!echo use tests/pdiff via extdiff extension for portability
   defaults.backout=-d "0 0"
   defaults.commit=-d "0 0"
   defaults.shelve=--date "0 0"
diff --git a/tests/test-commandserver.t b/tests/test-commandserver.t
--- a/tests/test-commandserver.t
+++ b/tests/test-commandserver.t
@@ -173,6 +173,7 @@  check that local configs for the cached 
   ...     runcommand(server, ['init', 'foo'])
   ...     runcommand(server, ['-R', 'foo', 'showconfig', 'ui', 'defaults'])
   *** runcommand showconfig
+  alias.extdiff=!echo use tests/pdiff via extdiff extension for portability
   bundle.mainreporoot=$TESTTMP/repo
   defaults.backout=-d "0 0"
   defaults.commit=-d "0 0"
diff --git a/tests/test-completion.t b/tests/test-completion.t
--- a/tests/test-completion.t
+++ b/tests/test-completion.t
@@ -17,6 +17,7 @@  Show all commands except debug commands
   copy
   diff
   export
+  extdiff
   files
   forget
   graft
@@ -274,6 +275,7 @@  Show all commands + options
   debugsuccessorssets: 
   debugwalk: include, exclude
   debugwireargs: three, four, five, ssh, remotecmd, insecure
+  extdiff: 
   files: rev, print0, include, exclude, template, subrepos
   graft: rev, continue, edit, log, force, currentdate, currentuser, date, user, tool, dry-run
   grep: print0, all, text, follow, ignore-case, files-with-matches, line-number, rev, user, date, include, exclude
diff --git a/tests/test-extdiff.t b/tests/test-extdiff.t
--- a/tests/test-extdiff.t
+++ b/tests/test-extdiff.t
@@ -9,6 +9,16 @@ 
   adding a
   adding b
 
+Check guard configuration and invalidate it to test extdiff itself
+
+  $ hg extdiff
+  use tests/pdiff via extdiff extension for portability
+
+  $ cat <<EOF >> $HGRCPATH
+  > [alias]
+  > extdiff = extdiff
+  > EOF
+
 Should diff cloned directories:
 
   $ hg extdiff -o -r $opt
diff --git a/tests/test-extension.t b/tests/test-extension.t
--- a/tests/test-extension.t
+++ b/tests/test-extension.t
@@ -1,3 +1,10 @@ 
+Invalidate guard configuration to make original one visible
+
+  $ cat <<EOF >> $HGRCPATH
+  > [alias]
+  > extdiff = extdiff
+  > EOF
+
 Test basic extension support
 
   $ cat > foobar.py <<EOF
@@ -382,6 +389,8 @@  Extension module help vs command help:
   $ hg help extdiff
   hg extdiff [OPT]... [FILE]...
   
+  alias for: hg extdiff
+  
   use external program to diff repository (or selected files)
   
       Show differences between revisions for the specified files, using an
diff --git a/tests/test-help.t b/tests/test-help.t
--- a/tests/test-help.t
+++ b/tests/test-help.t
@@ -2027,6 +2027,13 @@  Dish up an empty repo; serve it cold.
   mark files as copied for the next commit
   </td></tr>
   <tr><td>
+  <a href="/help/extdiff">
+  extdiff
+  </a>
+  </td><td>
+  (no help text available)
+  </td></tr>
+  <tr><td>
   <a href="/help/files">
   files
   </a>
diff --git a/tests/test-hgweb-json.t b/tests/test-hgweb-json.t
--- a/tests/test-hgweb-json.t
+++ b/tests/test-hgweb-json.t
@@ -936,6 +936,10 @@  help/ shows help topics
         "topic": "copy"
       },
       {
+        "summary": "(no help text available)",
+        "topic": "extdiff"
+      },
+      {
         "summary": "list tracked files",
         "topic": "files"
       },