[Buildbot-commits] buildbot/buildbot/test test_runner.py,1.10,1.11

Brian Warner warner at users.sourceforge.net
Fri Oct 21 08:03:41 UTC 2005


Update of /cvsroot/buildbot/buildbot/buildbot/test
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28628/buildbot/test

Modified Files:
	test_runner.py 
Log Message:
Revision: arch at buildbot.sf.net--2004/buildbot--dev--0--patch-348
Creator:  Brian Warner <warner at lothar.com>

add HTML/IRC control over build-on-branch and build-revision

	* buildbot/status/words.py (IrcStatusBot.command_FORCE): add
	control over --branch and --revision, not that they are always
	legal to provide
	* buildbot/status/html.py (StatusResourceBuilder.force): same
	(StatusResourceBuild.body): display SourceStamp components

	* buildbot/scripts/runner.py (ForceOptions): option parser for the
	IRC 'force' command, so it can be shared with an eventual
	command-line-tool 'buildbot force' mode.
	* buildbot/test/test_runner.py (Options.testForceOptions): test it


Index: test_runner.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_runner.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- test_runner.py	31 Aug 2005 01:51:25 -0000	1.10
+++ test_runner.py	21 Oct 2005 08:03:38 -0000	1.11
@@ -2,8 +2,8 @@
 # this file tests the 'buildbot' command, with its various sub-commands
 
 from twisted.trial import unittest
-from twisted.python import runtime
-import os, os.path, shutil
+from twisted.python import runtime, usage
+import os, os.path, shutil, shlex
 
 from buildbot.scripts import runner, tryclient
 
@@ -41,6 +41,32 @@
         os.makedirs(os.sep.join(["nothome", "dir1"]))
         self.check(["nothome", "dir1"], None)
 
+    def doForce(self, args, expected):
+        o = runner.ForceOptions()
+        o.parseOptions(args)
+        self.failUnlessEqual(o.keys(), expected.keys())
+        for k in o.keys():
+            self.failUnlessEqual(o[k], expected[k],
+                                 "[%s] got %s instead of %s" % (k, o[k],
+                                                                expected[k]))
+
+    def testForceOptions(self):
+        exp = {"builder": "b1", "reason": "reason",
+               "branch": None, "revision": None}
+        self.doForce(shlex.split("b1 reason"), exp)
+        self.doForce(shlex.split("b1 'reason'"), exp)
+        self.failUnlessRaises(usage.UsageError, self.doForce,
+                              shlex.split("--builder b1 'reason'"), exp)
+        self.doForce(shlex.split("--builder b1 --reason reason"), exp)
+        self.doForce(shlex.split("--builder b1 --reason 'reason'"), exp)
+        self.doForce(shlex.split("--builder b1 --reason \"reason\""), exp)
+        
+        exp['reason'] = "longer reason"
+        self.doForce(shlex.split("b1 'longer reason'"), exp)
+        self.doForce(shlex.split("b1 longer reason"), exp)
+        self.doForce(shlex.split("--reason 'longer reason' b1"), exp)
+        
+
 class Create(unittest.TestCase):
     def failUnlessIn(self, substring, string, msg=None):
         # trial provides a version of this that requires python-2.3 to test





More information about the Commits mailing list