Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3)

Unified Diff: third_party/buildbot_8_4p1/buildbot/test/unit/test_status_builder_cache.py

Issue 9703108: Switch to the good LRU implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build/
Patch Set: Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/buildbot_8_4p1/buildbot/test/unit/test_status_builder_cache.py
===================================================================
--- third_party/buildbot_8_4p1/buildbot/test/unit/test_status_builder_cache.py (revision 0)
+++ third_party/buildbot_8_4p1/buildbot/test/unit/test_status_builder_cache.py (revision 0)
@@ -0,0 +1,70 @@
+# This file is part of Buildbot. Buildbot is free software: you can
+# redistribute it and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation, version 2.
+#
+# This program is distributed in the hope that it will be useful, but WITHOUT
+# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program; if not, write to the Free Software Foundation, Inc., 51
+# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+# Copyright Buildbot Team Members
+
+import os
+from mock import Mock
+from twisted.trial import unittest
+from buildbot.status import builder, master
+
+class TestBuildStatus(unittest.TestCase):
+
+ # that buildstep.BuildStepStatus is never instantiated here should tell you
+ # that these classes are not well isolated!
+
+ def setupBuilder(self, buildername, category=None):
+ b = builder.BuilderStatus(buildername=buildername, category=category)
+ # Awkwardly, Status sets this member variable.
+ b.basedir = os.path.abspath(self.mktemp())
+ os.mkdir(b.basedir)
+ # Otherwise, builder.nextBuildNumber is not defined.
+ b.determineNextBuildNumber()
+ # Must initialize these fields before pickling.
+ b.currentBigState = 'idle'
+ b.status = 'idle'
+ return b
+
+ def setupStatus(self, b):
+ m = Mock()
+ m.buildbotURL = 'http://buildbot:8010/'
+ m.basedir = '/basedir'
+ s = master.Status(m)
+ b.status = s
+ return s
+
+ def testBuildCache(self):
+ b = self.setupBuilder('builder_1')
+ builds = []
+ for i in xrange(5):
+ build = b.newBuild()
+ build.setProperty('propkey', 'propval%d' % i, 'test')
+ builds.append(build)
+ build.buildStarted(build)
+ build.buildFinished()
+ for build in builds:
+ build2 = b.getBuild(build.number)
+ self.assertTrue(build2)
+ self.assertEqual(build2.number, build.number)
+ self.assertEqual(build.getProperty('propkey'),
+ 'propval%d' % build.number)
+ # Do another round, to make sure we're hitting the cache
+ hits = b.buildCache.hits
+ for build in builds:
+ build2 = b.getBuild(build.number)
+ self.assertTrue(build2)
+ self.assertEqual(build2.number, build.number)
+ self.assertEqual(build.getProperty('propkey'),
+ 'propval%d' % build.number)
+ self.assertEqual(b.buildCache.hits, hits+1)
+ hits = hits + 1
Property changes on: third_party/buildbot_8_4p1/buildbot/test/unit/test_status_builder_cache.py
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « third_party/buildbot_8_4p1/buildbot/status/builder.py ('k') | third_party/buildbot_8_4p1/buildbot/util/lru.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698