[Buildbot-commits] buildbot/buildbot/test test_scheduler.py,1.7,1.8

Brian Warner warner at users.sourceforge.net
Sat Nov 26 02:09:26 UTC 2005


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

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

add cron-style 'scheduler.Nightly', thanks to Dobes Vandermeer

	* docs/buildbot.texinfo (Scheduler Types): give a few hints about
	what Schedulers are available

	* buildbot/scheduler.py (Nightly): add new Scheduler based upon
	work by Dobes Vandermeer and hacked mercilessly by me. This offers
	'cron'-style build scheduling at certain times of day, week,
	month, or year.
	* buildbot/test/test_scheduler.py (Scheduling.testNightly): test it


Index: test_scheduler.py
===================================================================
RCS file: /cvsroot/buildbot/buildbot/buildbot/test/test_scheduler.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- test_scheduler.py	25 Nov 2005 23:26:35 -0000	1.7
+++ test_scheduler.py	26 Nov 2005 02:09:24 -0000	1.8
@@ -1,6 +1,6 @@
 # -*- test-case-name: buildbot.test.test_scheduler -*-
 
-import os
+import os, time
 
 from twisted.trial import unittest
 from twisted.internet import defer, reactor
@@ -46,6 +46,42 @@
         s1 = self.master.sets[0]
         self.failUnlessEqual(s1.builderNames, ["a","b"])
 
+    def testNightly(self):
+        # now == 15-Nov-2005, 00:05:36 AM . By using mktime, this is
+        # converted into the local timezone, which happens to match what
+        # Nightly is going to do anyway.
+        MIN=60; HOUR=60*MIN; DAY=24*3600
+        now = time.mktime((2005, 11, 15, 0, 5, 36, 1, 319, 0))
+
+        s = scheduler.Nightly('nightly', ["a"], hour=3)
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), 2*HOUR+54*MIN+24)
+
+        s = scheduler.Nightly('nightly', ["a"], minute=[3,8,54])
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), 2*MIN+24)
+
+        s = scheduler.Nightly('nightly', ["a"],
+                              dayOfMonth=16, hour=1, minute=6)
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), DAY+HOUR+24)
+
+        s = scheduler.Nightly('nightly', ["a"],
+                              dayOfMonth=16, hour=1, minute=3)
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), DAY+57*MIN+24)
+
+        s = scheduler.Nightly('nightly', ["a"],
+                              dayOfMonth=15, hour=1, minute=3)
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), 57*MIN+24)
+
+        s = scheduler.Nightly('nightly', ["a"],
+                              dayOfMonth=15, hour=0, minute=3)
+        t = s.calculateNextRunTimeFrom(now)
+        self.failUnlessEqual(int(t-now), 30*DAY-3*MIN+24)
+
+
     def isImportant(self, change):
         if "important" in change.files:
             return True





More information about the Commits mailing list