# HG changeset patch # User Steven Brown # Date 2011-04-25 10:00:30 # Node ID b69471bdb6783cabe1d94003b0e32764e831ea5b # Parent d7b4d421b56c4167663041aa5ee840112bdcf726 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. diff --git a/tests/notcapable b/tests/notcapable new file mode 100644 --- /dev/null +++ b/tests/notcapable @@ -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 diff --git a/tests/test-push-http.t b/tests/test-push-http.t --- a/tests/test-push-http.t +++ b/tests/test-push-http.t @@ -68,17 +68,8 @@ expect success 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