[PATCH] tests: unify test-extension

Adrian Buehlmann adrian at cadifra.com
Fri Sep 3 04:25:15 CDT 2010


# HG changeset patch
# User Adrian Buehlmann <adrian at cadifra.com>
# Date 1283505590 -7200
# Node ID 6e7cd7021a7131e20ccd40285eb64a70c97efa82
# Parent  40d099043c80167c80e1d4ad106f62b1762dcd66
tests: unify test-extension

diff --git a/tests/test-extension.out b/tests/test-extension.out
deleted file mode 100644
--- a/tests/test-extension.out
+++ /dev/null
@@ -1,134 +0,0 @@
-uisetup called
-reposetup called for a
-ui == repo.ui
-Foo
-uisetup called
-reposetup called for a
-ui == repo.ui
-reposetup called for b
-ui == repo.ui
-updating to branch default
-1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-uisetup called
-Bar
-% module/__init__.py-style
-uisetup called
-reposetup called for a
-ui == repo.ui
-Foo
-1) foo imported
-1) bar imported
-2) foo uisetup
-2) bar uisetup
-3) foo extsetup
-3) bar extsetup
-4) foo reposetup
-4) bar reposetup
-% hgweb.cgi
-1) foo imported
-1) bar imported
-2) foo uisetup
-2) bar uisetup
-3) foo extsetup
-3) bar extsetup
-4) foo reposetup
-4) bar reposetup
-4) foo reposetup
-4) bar reposetup
-empty extension - empty cmdtable
-
-no commands defined
-% hg help
-debugextension extension - only debugcommands
-
-no commands defined
-% hg help --verbose
-debugextension extension - only debugcommands
-
-list of commands:
-
- foo:
-      yet another foo command
-
-global options:
- -R --repository REPO    repository root directory or name of overlay bundle
-                         file
-    --cwd DIR            change working directory
- -y --noninteractive     do not prompt, assume 'yes' for any required answers
- -q --quiet              suppress output
- -v --verbose            enable additional output
-    --config CONFIG [+]  set/override config option (use 'section.name=value')
-    --debug              enable debugging output
-    --debugger           start debugger
-    --encoding ENCODE    set the charset encoding (default: ascii)
-    --encodingmode MODE  set the charset encoding mode (default: strict)
-    --traceback          always print a traceback on exception
-    --time               time how long the command takes
-    --profile            print command execution profile
-    --version            output version information and exit
- -h --help               display help and exit
-
-[+] marked option can be specified multiple times
-% hg help --debug
-debugextension extension - only debugcommands
-
-list of commands:
-
- debugfoobar:
-      yet another debug command
- foo:
-      yet another foo command
-
-global options:
- -R --repository REPO    repository root directory or name of overlay bundle
-                         file
-    --cwd DIR            change working directory
- -y --noninteractive     do not prompt, assume 'yes' for any required answers
- -q --quiet              suppress output
- -v --verbose            enable additional output
-    --config CONFIG [+]  set/override config option (use 'section.name=value')
-    --debug              enable debugging output
-    --debugger           start debugger
-    --encoding ENCODE    set the charset encoding (default: ascii)
-    --encodingmode MODE  set the charset encoding mode (default: strict)
-    --traceback          always print a traceback on exception
-    --time               time how long the command takes
-    --profile            print command execution profile
-    --version            output version information and exit
- -h --help               display help and exit
-
-[+] marked option can be specified multiple times
-% issue811
-% show extensions
-debugissue811
-mq
-% disabled extension commands
-'email' is provided by the following extension:
-
-    patchbomb  command to send changesets as (a series of) patch emails
-
-use "hg help extensions" for information on enabling extensions
-hg: unknown command 'qdel'
-'qdelete' is provided by the following extension:
-
-    mq  manage a stack of patches
-
-use "hg help extensions" for information on enabling extensions
-hg: unknown command 'churn'
-'churn' is provided by the following extension:
-
-    churn  command to display statistics about repository history
-
-use "hg help extensions" for information on enabling extensions
-% disabled extensions
-churn extension - command to display statistics about repository history
-
-use "hg help extensions" for information on enabling extensions
-patchbomb extension - command to send changesets as (a series of) patch emails
-
-use "hg help extensions" for information on enabling extensions
-% broken disabled extension and command
-broken extension - (no help text available)
-
-use "hg help extensions" for information on enabling extensions
-hg: unknown command 'foo'
diff --git a/tests/test-extension b/tests/test-extension.t
old mode 100755
new mode 100644
rename from tests/test-extension
rename to tests/test-extension.t
--- a/tests/test-extension
+++ b/tests/test-extension.t
@@ -1,181 +1,320 @@
-#!/bin/sh
-# Test basic extension support
+Test basic extension support
 
-"$TESTDIR/hghave" no-outer-repo || exit 80
+  $ "$TESTDIR/hghave" no-outer-repo || exit 80
 
-cat > foobar.py <<EOF
-import os
-from mercurial import commands
+  $ cat > foobar.py <<EOF
+  > import os
+  > from mercurial import commands
+  > 
+  > def uisetup(ui):
+  >     ui.write("uisetup called\\n")
+  > 
+  > def reposetup(ui, repo):
+  >     ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
+  >     ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
+  > 
+  > def foo(ui, *args, **kwargs):
+  >     ui.write("Foo\\n")
+  > 
+  > def bar(ui, *args, **kwargs):
+  >     ui.write("Bar\\n")
+  > 
+  > cmdtable = {
+  >    "foo": (foo, [], "hg foo"),
+  >    "bar": (bar, [], "hg bar"),
+  > }
+  > 
+  > commands.norepo += ' bar'
+  > EOF
+  $ abspath=`pwd`/foobar.py
 
-def uisetup(ui):
-    ui.write("uisetup called\\n")
+  $ mkdir barfoo
+  $ cp foobar.py barfoo/__init__.py
+  $ barfoopath=`pwd`/barfoo
 
-def reposetup(ui, repo):
-    ui.write("reposetup called for %s\\n" % os.path.basename(repo.root))
-    ui.write("ui %s= repo.ui\\n" % (ui == repo.ui and "=" or "!"))
+  $ hg init a
+  $ cd a
+  $ echo foo > file
+  $ hg add file
+  $ hg commit -m 'add file'
 
-def foo(ui, *args, **kwargs):
-    ui.write("Foo\\n")
+  $ echo '[extensions]' >> $HGRCPATH
+  $ echo "foobar = $abspath" >> $HGRCPATH
+  $ hg foo
+  uisetup called
+  reposetup called for a
+  ui == repo.ui
+  Foo
 
-def bar(ui, *args, **kwargs):
-    ui.write("Bar\\n")
+  $ cd ..
+  $ hg clone a b
+  uisetup called
+  reposetup called for a
+  ui == repo.ui
+  reposetup called for b
+  ui == repo.ui
+  updating to branch default
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
 
-cmdtable = {
-    "foo": (foo, [], "hg foo"),
-    "bar": (bar, [], "hg bar"),
-}
+  $ hg bar
+  uisetup called
+  Bar
+  $ echo 'foobar = !' >> $HGRCPATH
 
-commands.norepo += ' bar'
-EOF
-abspath=`pwd`/foobar.py
+module/__init__.py-style
 
-mkdir barfoo
-cp foobar.py barfoo/__init__.py
-barfoopath=`pwd`/barfoo
+  $ echo "barfoo = $barfoopath" >> $HGRCPATH
+  $ cd a
+  $ hg foo
+  uisetup called
+  reposetup called for a
+  ui == repo.ui
+  Foo
+  $ echo 'barfoo = !' >> $HGRCPATH
 
-hg init a
-cd a
-echo foo > file
-hg add file
-hg commit -m 'add file'
+Check that extensions are loaded in phases:
 
-echo '[extensions]' >> $HGRCPATH
-echo "foobar = $abspath" >> $HGRCPATH
-hg foo
+  $ cat > foo.py <<EOF
+  > import os
+  > name = os.path.basename(__file__).rsplit('.', 1)[0]
+  > print "1) %s imported" % name
+  > def uisetup(ui):
+  >     print "2) %s uisetup" % name
+  > def extsetup():
+  >     print "3) %s extsetup" % name
+  > def reposetup(ui, repo):
+  >    print "4) %s reposetup" % name
+  > EOF
 
-cd ..
-hg clone a b
+  $ cp foo.py bar.py
+  $ echo 'foo = foo.py' >> $HGRCPATH
+  $ echo 'bar = bar.py' >> $HGRCPATH
 
-hg bar
-echo 'foobar = !' >> $HGRCPATH
+Command with no output, we just want to see the extensions loaded:
 
-echo '% module/__init__.py-style'
-echo "barfoo = $barfoopath" >> $HGRCPATH
-cd a
-hg foo
-echo 'barfoo = !' >> $HGRCPATH
+  $ hg paths
+  1) foo imported
+  1) bar imported
+  2) foo uisetup
+  2) bar uisetup
+  3) foo extsetup
+  3) bar extsetup
+  4) foo reposetup
+  4) bar reposetup
 
-# check that extensions are loaded in phases
-cat > foo.py <<EOF
-import os
-name = os.path.basename(__file__).rsplit('.', 1)[0]
-print "1) %s imported" % name
-def uisetup(ui):
-    print "2) %s uisetup" % name
-def extsetup():
-    print "3) %s extsetup" % name
-def reposetup(ui, repo):
-    print "4) %s reposetup" % name
-EOF
+Check hgweb's load order:
 
-cp foo.py bar.py
-echo 'foo = foo.py' >> $HGRCPATH
-echo 'bar = bar.py' >> $HGRCPATH
+  $ cat > hgweb.cgi <<EOF
+  > #!/usr/bin/env python
+  > from mercurial import demandimport; demandimport.enable()
+  > from mercurial.hgweb import hgweb
+  > from mercurial.hgweb import wsgicgi
+  > 
+  > application = hgweb('.', 'test repo')
+  > wsgicgi.launch(application)
+  > EOF
 
-# command with no output, we just want to see the extensions loaded
-hg paths
+  $ SCRIPT_NAME='/' SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
+  >    | grep '^[0-9]) ' # ignores HTML output
+  1) foo imported
+  1) bar imported
+  2) foo uisetup
+  2) bar uisetup
+  3) foo extsetup
+  3) bar extsetup
+  4) foo reposetup
+  4) bar reposetup
+  4) foo reposetup
+  4) bar reposetup
 
-# check hgweb's load order
-echo '% hgweb.cgi'
-cat > hgweb.cgi <<EOF
-#!/usr/bin/env python
-from mercurial import demandimport; demandimport.enable()
-from mercurial.hgweb import hgweb
-from mercurial.hgweb import wsgicgi
+  $ echo 'foo = !' >> $HGRCPATH
+  $ echo 'bar = !' >> $HGRCPATH
 
-application = hgweb('.', 'test repo')
-wsgicgi.launch(application)
-EOF
-SCRIPT_NAME='/' SERVER_PORT='80' SERVER_NAME='localhost' python hgweb.cgi \
-    | grep '^[0-9]) ' # ignores HTML output
+  $ cd ..
 
-echo 'foo = !' >> $HGRCPATH
-echo 'bar = !' >> $HGRCPATH
+  $ cat > empty.py <<EOF
+  > '''empty cmdtable
+  > '''
+  > cmdtable = {}
+  > EOF
+  $ emptypath=`pwd`/empty.py
+  $ echo "empty = $emptypath" >> $HGRCPATH
+  $ hg help empty
+  empty extension - empty cmdtable
+  
+  no commands defined
 
-cd ..
-cat > empty.py <<EOF
-'''empty cmdtable
-'''
-cmdtable = {}
-EOF
-emptypath=`pwd`/empty.py
-echo "empty = $emptypath" >> $HGRCPATH
-hg help empty
-echo 'empty = !' >> $HGRCPATH
+  $ echo 'empty = !' >> $HGRCPATH
 
-cat > debugextension.py <<EOF
-'''only debugcommands
-'''
-def debugfoobar(ui, repo, *args, **opts):
-    "yet another debug command"
-    pass
+  $ cat > debugextension.py <<EOF
+  > '''only debugcommands
+  > '''
+  > def debugfoobar(ui, repo, *args, **opts):
+  >     "yet another debug command"
+  >     pass
+  > 
+  > def foo(ui, repo, *args, **opts):
+  >     """yet another foo command
+  > 
+  >     This command has been DEPRECATED since forever.
+  >     """
+  >     pass
+  > 
+  > cmdtable = {
+  >    "debugfoobar": (debugfoobar, (), "hg debugfoobar"),
+  >    "foo": (foo, (), "hg foo")
+  > }
+  > EOF
+  $ debugpath=`pwd`/debugextension.py
+  $ echo "debugextension = $debugpath" >> $HGRCPATH
 
-def foo(ui, repo, *args, **opts):
-    """yet another foo command
+  $ hg help debugextension
+  debugextension extension - only debugcommands
+  
+  no commands defined
 
-    This command has been DEPRECATED since forever.
-    """
-    pass
+  $ hg --verbose help debugextension
+  debugextension extension - only debugcommands
+  
+  list of commands:
+  
+   foo:
+        yet another foo command
+  
+  global options:
+   -R --repository REPO    repository root directory or name of overlay bundle
+                           file
+      --cwd DIR            change working directory
+   -y --noninteractive     do not prompt, assume 'yes' for any required answers
+   -q --quiet              suppress output
+   -v --verbose            enable additional output
+      --config CONFIG [+]  set/override config option (use 'section.name=value')
+      --debug              enable debugging output
+      --debugger           start debugger
+      --encoding ENCODE    set the charset encoding (default: ascii)
+      --encodingmode MODE  set the charset encoding mode (default: strict)
+      --traceback          always print a traceback on exception
+      --time               time how long the command takes
+      --profile            print command execution profile
+      --version            output version information and exit
+   -h --help               display help and exit
+  
+  [+] marked option can be specified multiple times
 
-cmdtable = {
-    "debugfoobar": (debugfoobar, (), "hg debugfoobar"),
-    "foo": (foo, (), "hg foo")
-}
-EOF
-debugpath=`pwd`/debugextension.py
-echo "debugextension = $debugpath" >> $HGRCPATH
-echo "% hg help"
-hg help debugextension
-echo "% hg help --verbose"
-hg --verbose help debugextension
-echo "% hg help --debug"
-hg --debug help debugextension
-echo 'debugextension = !' >> $HGRCPATH
+  $ hg --debug help debugextension
+  debugextension extension - only debugcommands
+  
+  list of commands:
+  
+   debugfoobar:
+        yet another debug command
+   foo:
+        yet another foo command
+  
+  global options:
+   -R --repository REPO    repository root directory or name of overlay bundle
+                           file
+      --cwd DIR            change working directory
+   -y --noninteractive     do not prompt, assume 'yes' for any required answers
+   -q --quiet              suppress output
+   -v --verbose            enable additional output
+      --config CONFIG [+]  set/override config option (use 'section.name=value')
+      --debug              enable debugging output
+      --debugger           start debugger
+      --encoding ENCODE    set the charset encoding (default: ascii)
+      --encodingmode MODE  set the charset encoding mode (default: strict)
+      --traceback          always print a traceback on exception
+      --time               time how long the command takes
+      --profile            print command execution profile
+      --version            output version information and exit
+   -h --help               display help and exit
+  
+  [+] marked option can be specified multiple times
+  $ echo 'debugextension = !' >> $HGRCPATH
 
-echo % issue811
-debugpath=`pwd`/debugissue811.py
-cat > debugissue811.py <<EOF
-'''show all loaded extensions
-'''
-from mercurial import extensions, commands
+Issue811:
 
-def debugextensions(ui):
-    "yet another debug command"
-    ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
+  $ debugpath=`pwd`/debugissue811.py
+  $ cat > debugissue811.py <<EOF
+  > '''show all loaded extensions
+  > '''
+  > from mercurial import extensions, commands
+  > 
+  > def debugextensions(ui):
+  >     "yet another debug command"
+  >     ui.write("%s\n" % '\n'.join([x for x, y in extensions.extensions()]))
+  > 
+  > cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")}
+  > commands.norepo += " debugextensions"
+  > EOF
+  $ echo "debugissue811 = $debugpath" >> $HGRCPATH
+  $ echo "mq=" >> $HGRCPATH
+  $ echo "hgext.mq=" >> $HGRCPATH
+  $ echo "hgext/mq=" >> $HGRCPATH
 
-cmdtable = {"debugextensions": (debugextensions, (), "hg debugextensions")}
-commands.norepo += " debugextensions"
-EOF
-echo "debugissue811 = $debugpath" >> $HGRCPATH
-echo "mq=" >> $HGRCPATH
-echo "hgext.mq=" >> $HGRCPATH
-echo "hgext/mq=" >> $HGRCPATH
+Show extensions:
 
-echo % show extensions
-hg debugextensions
+  $ hg debugextensions
+  debugissue811
+  mq
 
-echo '% disabled extension commands'
-HGRCPATH=
-export HGRCPATH
-hg help email
-hg qdel
-hg churn
-echo '% disabled extensions'
-hg help churn
-hg help patchbomb
-echo '% broken disabled extension and command'
-mkdir hgext
-echo > hgext/__init__.py
-cat > hgext/broken.py <<EOF
-"broken extension'
-EOF
-cat > path.py <<EOF
-import os, sys
-sys.path.insert(0, os.environ['HGEXTPATH'])
-EOF
-HGEXTPATH=`pwd`
-export HGEXTPATH
-hg --config extensions.path=./path.py help broken
-hg --config extensions.path=./path.py help foo > /dev/null
+Disabled extension commands:
 
-exit 0
+  $ HGRCPATH=
+  $ export HGRCPATH
+  $ hg help email
+  'email' is provided by the following extension:
+  
+      patchbomb  command to send changesets as (a series of) patch emails
+  
+  use "hg help extensions" for information on enabling extensions
+  $ hg qdel
+  hg: unknown command 'qdel'
+  'qdelete' is provided by the following extension:
+  
+      mq  manage a stack of patches
+  
+  use "hg help extensions" for information on enabling extensions
+  $ hg churn
+  hg: unknown command 'churn'
+  'churn' is provided by the following extension:
+  
+      churn  command to display statistics about repository history
+  
+  use "hg help extensions" for information on enabling extensions
+
+Disabled extensions:
+
+  $ hg help churn
+  churn extension - command to display statistics about repository history
+  
+  use "hg help extensions" for information on enabling extensions
+  $ hg help patchbomb
+  patchbomb extension - command to send changesets as (a series of) patch emails
+  
+  use "hg help extensions" for information on enabling extensions
+
+Broken disabled extension and command:
+
+  $ mkdir hgext
+  $ echo > hgext/__init__.py
+  $ cat > hgext/broken.py <<EOF
+  > "broken extension'
+  > EOF
+  $ cat > path.py <<EOF
+  > import os, sys
+  > sys.path.insert(0, os.environ['HGEXTPATH'])
+  > EOF
+  $ HGEXTPATH=`pwd`
+  $ export HGEXTPATH
+
+  $ hg --config extensions.path=./path.py help broken
+  broken extension - (no help text available)
+  
+  use "hg help extensions" for information on enabling extensions
+
+  $ hg --config extensions.path=./path.py help foo > /dev/null
+  hg: unknown command 'foo'
+
+  $ exit 0
+


More information about the Mercurial-devel mailing list