mirror of https://github.com/golang/go.git
codereview: revive the tests.
LGTM=rsc R=rsc CC=golang-codereviews https://golang.org/cl/105500043
This commit is contained in:
parent
2296928fe7
commit
9a8a20bdb8
|
|
@ -75,6 +75,7 @@ real_rollback = None
|
||||||
releaseBranch = None
|
releaseBranch = None
|
||||||
server = "codereview.appspot.com"
|
server = "codereview.appspot.com"
|
||||||
server_url_base = None
|
server_url_base = None
|
||||||
|
testing = None
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Normally I would split this into multiple files, but it simplifies
|
# Normally I would split this into multiple files, but it simplifies
|
||||||
|
|
@ -2285,6 +2286,10 @@ def norollback(*pats, **opts):
|
||||||
|
|
||||||
codereview_init = False
|
codereview_init = False
|
||||||
|
|
||||||
|
def uisetup(ui):
|
||||||
|
global testing
|
||||||
|
testing = ui.config("codereview", "testing")
|
||||||
|
|
||||||
def reposetup(ui, repo):
|
def reposetup(ui, repo):
|
||||||
global codereview_disabled
|
global codereview_disabled
|
||||||
global defaultcc
|
global defaultcc
|
||||||
|
|
@ -2327,7 +2332,7 @@ def reposetup(ui, repo):
|
||||||
return
|
return
|
||||||
|
|
||||||
remote = ui.config("paths", "default", "")
|
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,))
|
raise hg_util.Abort("codereview: default path '%s' is not a URL" % (remote,))
|
||||||
|
|
||||||
InstallMatch(ui, repo)
|
InstallMatch(ui, repo)
|
||||||
|
|
@ -2434,7 +2439,10 @@ def IsRietveldSubmitted(ui, clname, hex):
|
||||||
return False
|
return False
|
||||||
for msg in dict.get("messages", []):
|
for msg in dict.get("messages", []):
|
||||||
text = msg.get("text", "")
|
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)):
|
if m is not None and len(m.group(1)) >= 8 and hex.startswith(m.group(1)):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
@ -2539,6 +2547,8 @@ def MySend1(request_path, payload=None,
|
||||||
tries += 1
|
tries += 1
|
||||||
args = dict(kwargs)
|
args = dict(kwargs)
|
||||||
url = "https://%s%s" % (self.host, request_path)
|
url = "https://%s%s" % (self.host, request_path)
|
||||||
|
if testing:
|
||||||
|
url = url.replace("https://", "http://")
|
||||||
if args:
|
if args:
|
||||||
url += "?" + urllib.urlencode(args)
|
url += "?" + urllib.urlencode(args)
|
||||||
req = self._CreateRequest(url=url, data=payload)
|
req = self._CreateRequest(url=url, data=payload)
|
||||||
|
|
@ -2651,8 +2661,9 @@ def RietveldSetup(ui, repo):
|
||||||
email = x
|
email = x
|
||||||
|
|
||||||
server_url_base = "https://" + server + "/"
|
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)
|
force_google_account = ui.configbool("codereview", "force_google_account", False)
|
||||||
|
|
||||||
upload_options = opt()
|
upload_options = opt()
|
||||||
|
|
@ -2929,7 +2940,10 @@ class AbstractRpcServer(object):
|
||||||
# This is a dummy value to allow us to identify when we're successful.
|
# This is a dummy value to allow us to identify when we're successful.
|
||||||
continue_location = "http://localhost/"
|
continue_location = "http://localhost/"
|
||||||
args = {"continue": continue_location, "auth": auth_token}
|
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:
|
try:
|
||||||
response = self.opener.open(req)
|
response = self.opener.open(req)
|
||||||
except urllib2.HTTPError, e:
|
except urllib2.HTTPError, e:
|
||||||
|
|
@ -3020,6 +3034,8 @@ class AbstractRpcServer(object):
|
||||||
tries += 1
|
tries += 1
|
||||||
args = dict(kwargs)
|
args = dict(kwargs)
|
||||||
url = "https://%s%s" % (self.host, request_path)
|
url = "https://%s%s" % (self.host, request_path)
|
||||||
|
if testing:
|
||||||
|
url = url.replace("https://", "http://")
|
||||||
if args:
|
if args:
|
||||||
url += "?" + urllib.urlencode(args)
|
url += "?" + urllib.urlencode(args)
|
||||||
req = self._CreateRequest(url=url, data=payload)
|
req = self._CreateRequest(url=url, data=payload)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
# Assumes a local Rietveld is running using the App Engine SDK
|
# Assumes a local Rietveld is running using the App Engine SDK
|
||||||
# at http://localhost:7777/
|
# 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
|
codereview_script=$(pwd)/codereview.py
|
||||||
server=localhost:7777
|
server=localhost:7777
|
||||||
|
|
@ -57,6 +57,7 @@ username=Grace R Emlin <gre@golang.org>
|
||||||
[extensions]
|
[extensions]
|
||||||
codereview=$codereview_script
|
codereview=$codereview_script
|
||||||
[codereview]
|
[codereview]
|
||||||
|
testing=true
|
||||||
server=$server
|
server=$server
|
||||||
" >>$clone1/.hg/hgrc
|
" >>$clone1/.hg/hgrc
|
||||||
cp $clone1/.hg/hgrc $clone2/.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
|
must hg add lib/codereview/codereview.cfg CONTRIBUTORS
|
||||||
|
|
||||||
status First submit.
|
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
|
lib/codereview/codereview.cfg CONTRIBUTORS
|
||||||
|
|
||||||
status Should see change in other client.
|
status Should see change in other client.
|
||||||
|
|
@ -93,8 +94,8 @@ test_clpatch() {
|
||||||
# Clpatch will check.
|
# Clpatch will check.
|
||||||
|
|
||||||
cd $clone1
|
cd $clone1
|
||||||
# Tried to use UTF-8 here to test that, but dev_appserver.py crashes. Ha ha.
|
# dev_appserver.py used to crash with UTF-8 input.
|
||||||
if false; then
|
if true; then
|
||||||
status Using UTF-8.
|
status Using UTF-8.
|
||||||
name="Grácè T Emlïn <test@example.com>"
|
name="Grácè T Emlïn <test@example.com>"
|
||||||
else
|
else
|
||||||
|
|
@ -103,20 +104,20 @@ test_clpatch() {
|
||||||
fi
|
fi
|
||||||
echo "$name" >>CONTRIBUTORS
|
echo "$name" >>CONTRIBUTORS
|
||||||
cat .hg/hgrc | sed "s/Grace.*/$name/" >/tmp/x && mv /tmp/x .hg/hgrc
|
cat .hg/hgrc | sed "s/Grace.*/$name/" >/tmp/x && mv /tmp/x .hg/hgrc
|
||||||
echo '
|
echo "
|
||||||
Reviewer: gre@golang.org
|
Reviewer: gre@golang.org
|
||||||
Description:
|
Description:
|
||||||
CONTRIBUTORS: add $name
|
CONTRIBUTORS: add $name
|
||||||
Files:
|
Files:
|
||||||
CONTRIBUTORS
|
CONTRIBUTORS
|
||||||
' | must hg change -i
|
" | must hg change -i
|
||||||
num=$(hg pending | sed 1q | tr -d :)
|
num=$(hg pending | sed 1q | tr -d :)
|
||||||
|
|
||||||
status Patch CL.
|
status Patch CL.
|
||||||
cd $clone2
|
cd $clone2
|
||||||
must hg clpatch $num
|
must hg clpatch $num
|
||||||
must [ "$num" = "$(firstcl)" ]
|
must [ "$num" = "$(firstcl)" ]
|
||||||
must hg submit $num
|
must hg submit --tbr gre@golang.org $num
|
||||||
|
|
||||||
status Issue should be open with no reviewers.
|
status Issue should be open with no reviewers.
|
||||||
must curl http://$server/api/$num >/tmp/x
|
must curl http://$server/api/$num >/tmp/x
|
||||||
|
|
@ -160,7 +161,7 @@ Reviewer: gre@golang.org
|
||||||
Description: file1
|
Description: file1
|
||||||
Files: file1
|
Files: file1
|
||||||
' | must hg change -i
|
' | must hg change -i
|
||||||
must hg submit $(firstcl)
|
must hg submit --tbr gre@golang.org $(firstcl)
|
||||||
|
|
||||||
cd $clone2
|
cd $clone2
|
||||||
echo file2 >file2
|
echo file2 >file2
|
||||||
|
|
@ -170,9 +171,9 @@ Reviewer: gre@golang.org
|
||||||
Description: file2
|
Description: file2
|
||||||
Files: file2
|
Files: file2
|
||||||
' | must hg change -i
|
' | must hg change -i
|
||||||
must not hg submit $(firstcl)
|
must not hg submit --tbr gre@golang.org $(firstcl)
|
||||||
must hg sync
|
must hg sync
|
||||||
must hg submit $(firstcl)
|
must hg submit --tbr gre@golang.org $(firstcl)
|
||||||
}
|
}
|
||||||
|
|
||||||
test_restrict() {
|
test_restrict() {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue