[PATCH 6 of 6 V2] blackbox: tests for the blackbox extension

Durham Goode durham at fb.com
Tue Feb 12 17:12:58 CST 2013


# HG changeset patch
# User Durham Goode <durham at fb.com>
# Date 1360445730 28800
#      Sat Feb 09 13:35:30 2013 -0800
# Node ID fc1e598a1ba723af78442dccb9ef3dfc58e0ac0d
# Parent  4e7e236ebc7dad934c79fb2ee7665a78ffd712e5
blackbox: tests for the blackbox extension

A few tests to cover the blackbox extension. Covers commands, hooks, and
incoming changes.

diff --git a/tests/test-blackbox.t b/tests/test-blackbox.t
new file mode 100644
--- /dev/null
+++ b/tests/test-blackbox.t
@@ -0,0 +1,67 @@
+setup
+  $ cat > mock.py <<EOF
+  > from mercurial import util
+  > import getpass
+  > 
+  > def makedate():
+  >     return 0, 0
+  > def getuser():
+  >     return 'bob'
+  > # mock the date and user apis so the output is always the same
+  > def uisetup(ui):
+  >     util.makedate = makedate
+  >     getpass.getuser = getuser
+  > EOF
+  $ cat >> $HGRCPATH <<EOF
+  > [extensions]
+  > blackbox=
+  > mock=`pwd`/mock.py
+  > EOF
+  $ hg init blackboxtest
+  $ cd blackboxtest
+
+command, exit codes, and duration
+
+  $ echo a > a
+  $ hg add a
+  $ hg blackbox
+  1970/01/01 00:00:00 bob> add a
+  1970/01/01 00:00:00 bob> add exited 0 after * seconds (glob)
+
+extension and python hooks - use the eol extension for a pythonhook
+
+  $ echo '[extensions]' >> .hg/hgrc
+  $ echo 'eol=' >> .hg/hgrc
+  $ echo '[hooks]' >> .hg/hgrc
+  $ echo 'update = echo hooked' >> .hg/hgrc
+  $ hg update
+  hooked
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg blackbox -l 4
+  1970/01/01 00:00:00 bob> update
+  1970/01/01 00:00:00 bob> pythonhook-preupdate: hgext.eol.preupdate finished in * seconds (glob)
+  1970/01/01 00:00:00 bob> exthook-update: echo hooked finished in * seconds (glob)
+  1970/01/01 00:00:00 bob> update exited False after * seconds (glob)
+
+incoming change tracking
+
+  $ hg clone . ../blackboxtest2
+  updating to branch default
+  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg commit -ma
+  $ cd ../blackboxtest2
+  $ hg pull
+  pulling from $TESTTMP/blackboxtest
+  requesting all changes
+  adding changesets
+  adding manifests
+  adding file changes
+  added 1 changesets with 1 changes to 1 files
+  (run 'hg update' to get a working copy)
+  $ hg blackbox -l 3
+  1970/01/01 00:00:00 bob> pull
+  1970/01/01 00:00:00 bob> 1 incoming changes - new heads: cb9a9f314b8b (glob)
+  1970/01/01 00:00:00 bob> pull exited None after * seconds (glob)
+
+cleanup
+  $ cd ..


More information about the Mercurial-devel mailing list