summaryrefslogtreecommitdiff
path: root/lib/codereview
diff options
context:
space:
mode:
authorShenghou Ma <minux@golang.org>2014-07-18 21:00:35 -0400
committerShenghou Ma <minux@golang.org>2014-07-18 21:00:35 -0400
commitd3c59f0f76cd8dcd70e130aad855e41cfd4d2999 (patch)
treeca97c0f144f035b063376b452908d73a30f7f55e /lib/codereview
parent80e2eb1beab7e48d78292f956ed1dbb4f9b78e50 (diff)
downloadgo-d3c59f0f76cd8dcd70e130aad855e41cfd4d2999.tar.gz
codereview: revive the tests.
LGTM=rsc R=rsc CC=golang-codereviews https://codereview.appspot.com/105500043
Diffstat (limited to 'lib/codereview')
-rw-r--r--lib/codereview/codereview.py24
-rwxr-xr-xlib/codereview/test.sh21
2 files changed, 31 insertions, 14 deletions
diff --git a/lib/codereview/codereview.py b/lib/codereview/codereview.py
index f7db3870b..8445555fa 100644
--- a/lib/codereview/codereview.py
+++ b/lib/codereview/codereview.py
@@ -75,6 +75,7 @@ real_rollback = None
releaseBranch = None
server = "codereview.appspot.com"
server_url_base = None
+testing = None
#######################################################################
# Normally I would split this into multiple files, but it simplifies
@@ -2285,6 +2286,10 @@ def norollback(*pats, **opts):
codereview_init = False
+def uisetup(ui):
+ global testing
+ testing = ui.config("codereview", "testing")
+
def reposetup(ui, repo):
global codereview_disabled
global defaultcc
@@ -2327,7 +2332,7 @@ def reposetup(ui, repo):
return
remote = ui.config("paths", "default", "")
- if remote.find("://") < 0:
+ if remote.find("://") < 0 and not testing:
raise hg_util.Abort("codereview: default path '%s' is not a URL" % (remote,))
InstallMatch(ui, repo)
@@ -2434,7 +2439,10 @@ def IsRietveldSubmitted(ui, clname, hex):
return False
for msg in dict.get("messages", []):
text = msg.get("text", "")
- m = re.match('\*\*\* Submitted as [^*]*?r=([0-9a-f]+)[^ ]* \*\*\*', text)
+ regex = '\*\*\* Submitted as [^*]*?r=([0-9a-f]+)[^ ]* \*\*\*'
+ if testing:
+ regex = '\*\*\* Submitted as ([0-9a-f]+) \*\*\*'
+ m = re.match(regex, text)
if m is not None and len(m.group(1)) >= 8 and hex.startswith(m.group(1)):
return True
return False
@@ -2539,6 +2547,8 @@ def MySend1(request_path, payload=None,
tries += 1
args = dict(kwargs)
url = "https://%s%s" % (self.host, request_path)
+ if testing:
+ url = url.replace("https://", "http://")
if args:
url += "?" + urllib.urlencode(args)
req = self._CreateRequest(url=url, data=payload)
@@ -2651,8 +2661,9 @@ def RietveldSetup(ui, repo):
email = x
server_url_base = "https://" + server + "/"
+ if testing:
+ server_url_base = server_url_base.replace("https://", "http://")
- testing = ui.config("codereview", "testing")
force_google_account = ui.configbool("codereview", "force_google_account", False)
upload_options = opt()
@@ -2929,7 +2940,10 @@ class AbstractRpcServer(object):
# This is a dummy value to allow us to identify when we're successful.
continue_location = "http://localhost/"
args = {"continue": continue_location, "auth": auth_token}
- req = self._CreateRequest("https://%s/_ah/login?%s" % (self.host, urllib.urlencode(args)))
+ reqUrl = "https://%s/_ah/login?%s" % (self.host, urllib.urlencode(args))
+ if testing:
+ reqUrl = reqUrl.replace("https://", "http://")
+ req = self._CreateRequest(reqUrl)
try:
response = self.opener.open(req)
except urllib2.HTTPError, e:
@@ -3020,6 +3034,8 @@ class AbstractRpcServer(object):
tries += 1
args = dict(kwargs)
url = "https://%s%s" % (self.host, request_path)
+ if testing:
+ url = url.replace("https://", "http://")
if args:
url += "?" + urllib.urlencode(args)
req = self._CreateRequest(url=url, data=payload)
diff --git a/lib/codereview/test.sh b/lib/codereview/test.sh
index 13f2b9cda..4bef9b6c5 100755
--- a/lib/codereview/test.sh
+++ b/lib/codereview/test.sh
@@ -7,7 +7,7 @@
# Assumes a local Rietveld is running using the App Engine SDK
# at http://localhost:7777/
#
-# dev_appserver.py -p 7777 $HOME/pub/rietveld
+# dev_appserver.py --port 7777 $HOME/pub/rietveld
codereview_script=$(pwd)/codereview.py
server=localhost:7777
@@ -57,6 +57,7 @@ username=Grace R Emlin <gre@golang.org>
[extensions]
codereview=$codereview_script
[codereview]
+testing=true
server=$server
" >>$clone1/.hg/hgrc
cp $clone1/.hg/hgrc $clone2/.hg/hgrc
@@ -78,7 +79,7 @@ echo 'Grace R Emlin <gre@golang.org>' >CONTRIBUTORS
must hg add lib/codereview/codereview.cfg CONTRIBUTORS
status First submit.
-must hg submit -r gre@golang.org -m codereview \
+must hg submit --tbr gre@golang.org -m codereview \
lib/codereview/codereview.cfg CONTRIBUTORS
status Should see change in other client.
@@ -93,8 +94,8 @@ test_clpatch() {
# Clpatch will check.
cd $clone1
- # Tried to use UTF-8 here to test that, but dev_appserver.py crashes. Ha ha.
- if false; then
+ # dev_appserver.py used to crash with UTF-8 input.
+ if true; then
status Using UTF-8.
name="Grácè T Emlïn <test@example.com>"
else
@@ -103,20 +104,20 @@ test_clpatch() {
fi
echo "$name" >>CONTRIBUTORS
cat .hg/hgrc | sed "s/Grace.*/$name/" >/tmp/x && mv /tmp/x .hg/hgrc
- echo '
+ echo "
Reviewer: gre@golang.org
Description:
CONTRIBUTORS: add $name
Files:
CONTRIBUTORS
-' | must hg change -i
+" | must hg change -i
num=$(hg pending | sed 1q | tr -d :)
status Patch CL.
cd $clone2
must hg clpatch $num
must [ "$num" = "$(firstcl)" ]
- must hg submit $num
+ must hg submit --tbr gre@golang.org $num
status Issue should be open with no reviewers.
must curl http://$server/api/$num >/tmp/x
@@ -160,7 +161,7 @@ Reviewer: gre@golang.org
Description: file1
Files: file1
' | must hg change -i
- must hg submit $(firstcl)
+ must hg submit --tbr gre@golang.org $(firstcl)
cd $clone2
echo file2 >file2
@@ -170,9 +171,9 @@ Reviewer: gre@golang.org
Description: file2
Files: file2
' | must hg change -i
- must not hg submit $(firstcl)
+ must not hg submit --tbr gre@golang.org $(firstcl)
must hg sync
- must hg submit $(firstcl)
+ must hg submit --tbr gre@golang.org $(firstcl)
}
test_restrict() {