]> Cypherpunks.ru repositories - gostls13.git/commitdiff
codereview: revive the tests.
authorShenghou Ma <minux@golang.org>
Sat, 19 Jul 2014 01:00:35 +0000 (21:00 -0400)
committerShenghou Ma <minux@golang.org>
Sat, 19 Jul 2014 01:00:35 +0000 (21:00 -0400)
LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/105500043

lib/codereview/codereview.py
lib/codereview/test.sh

index f7db3870b035b4e722f2692beeb5eaf1dc2750db..8445555fa217ffd415d803ab196b7e7bee9cc47a 100644 (file)
@@ -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)
index 13f2b9cda70ff327cc4fec6a8609a361e6e6aabd..4bef9b6c5d5bca7c3cee68a1dd61c1a3a51aa6fe 100755 (executable)
@@ -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() {