changeset 34484:a8a9c0d3232b

test-alias: make it compatible with chg ad1bdea (dispatch: defer environment variable resolution in alias commands (BC), 2016-05-06) made environment variables lazily resolved. But after D805 (alias: make alias command lazily resolved 2017-09-23), alias resolution happened after uisetup, which breaks the test for chg. `uisetup` is known to behave different in chg. Let's verify the feature without using `*setup`. Differential Revision: https://phab.mercurial-scm.org/D912
author Jun Wu <quark@fb.com>
date Mon, 02 Oct 2017 16:48:58 -0700
parents a6d95a8b7243
children 37b7581e5737
files tests/test-alias.t
diffstat 1 files changed, 14 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-alias.t	Wed Oct 04 18:39:26 2017 -0700
+++ b/tests/test-alias.t	Mon Oct 02 16:48:58 2017 -0700
@@ -527,21 +527,29 @@
 
 environment variable changes in alias commands
 
-  $ cat > $TESTTMP/setcount.py <<EOF
+  $ cat > $TESTTMP/expandalias.py <<EOF
   > import os
-  > def uisetup(ui):
+  > from mercurial import cmdutil, commands, registrar
+  > cmdtable = {}
+  > command = registrar.command(cmdtable)
+  > @command('expandalias')
+  > def expandalias(ui, repo, name):
+  >     alias = cmdutil.findcmd(name, commands.table)[1][0]
+  >     ui.write('%s args: %s\n' % (name, ' '.join(alias.args)))
   >     os.environ['COUNT'] = '2'
+  >     ui.write('%s args: %s (with COUNT=2)\n' % (name, ' '.join(alias.args)))
   > EOF
 
   $ cat >> $HGRCPATH <<'EOF'
   > [extensions]
-  > setcount = $TESTTMP/setcount.py
+  > expandalias = $TESTTMP/expandalias.py
   > [alias]
-  > showcount = log -T "$COUNT\n" -r .
+  > showcount = log -T "$COUNT" -r .
   > EOF
 
-  $ COUNT=1 hg showcount
-  2
+  $ COUNT=1 hg expandalias showcount
+  showcount args: -T 1 -r .
+  showcount args: -T 2 -r . (with COUNT=2)
 
 This should show id: