tests: add script to disable a selected wire protocol capability
This can be used to test that the client and server both fall back to the
previous wire protocol when the capability is not supported.
It is currently used by test-push-http.t and I plan to use it for the HTTP
long argument support tests.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/notcapable Mon Apr 25 18:00:30 2011 +0800
@@ -0,0 +1,19 @@
+# Disable the $CAP wire protocol capability.
+
+if test -z "$CAP"
+then
+ echo "CAP environment variable not set."
+fi
+
+cat > notcapable-$CAP.py << EOF
+from mercurial import extensions, repo
+def extsetup():
+ extensions.wrapfunction(repo.repository, 'capable', wrapper)
+def wrapper(orig, self, name, *args, **kwargs):
+ if name == '$CAP':
+ return False
+ return orig(self, name, *args, **kwargs)
+EOF
+
+echo '[extensions]' >> $HGRCPATH
+echo "notcapable-$CAP = `pwd`/notcapable-$CAP.py" >> $HGRCPATH
--- a/tests/test-push-http.t Mon Apr 25 14:03:12 2011 +0200
+++ b/tests/test-push-http.t Mon Apr 25 18:00:30 2011 +0800
@@ -68,17 +68,8 @@
expect success, server lacks the unbundlehash capability
- $ cat > unbundlehash-off.py << EOF
- > from mercurial import extensions, repo
- > def extsetup():
- > extensions.wrapfunction(repo.repository, 'capable', wrapper)
- > def wrapper(orig, self, name, *args, **kwargs):
- > if name == 'unbundlehash':
- > return False
- > return orig(self, name, *args, **kwargs)
- > EOF
- $ echo '[extensions]' >> .hg/hgrc
- $ echo "unbundlehash-off = `pwd`/unbundlehash-off.py" >> .hg/hgrc
+ $ CAP=unbundlehash
+ $ . "$TESTDIR/notcapable"
$ req
pushing to http://localhost:$HGPORT/
searching for changes