Permalink
Browse files

tweak magit builds

  • Loading branch information...
1 parent 6532209 commit b2894987786cfc4f6e9ac78a6e4cf78adbb037af @sigma committed Mar 29, 2012
Showing with 78 additions and 6 deletions.
  1. +5 −4 emacs/projects/_base.py
  2. +43 −2 emacs/projects/magit.py
  3. +30 −0 emacs/utils.py
@@ -64,18 +64,19 @@ def getAssignments(self):
assignments = []
for combo in product(*values):
- combo_tag = dict(zip(keys, combo))
+ combo_tag = {}
slaves = []
for slave in self._slaves:
fits = True
- for key, val in zip(keys, combo):
+ for key, expected in zip(keys, combo):
if not slave.properties.has_key("slave/features/" + key):
fits = False
break
- if not self.validateFeature(
- slave.properties['slave/features/' + key], val):
+ proposed = slave.properties['slave/features/' + key]
+ if not self.validateFeature(proposed, expected):
fits = False
break
+ combo_tag[key] = proposed
if fits:
slaves.append(slave.slavename)
if slaves:
@@ -4,8 +4,9 @@
from buildbot.steps.source import Git
from buildbot.process.properties import WithProperties
-from ..steps import EmacsCompile
+from ..steps import EmacsCompile, EmacsTest
from ..versions import EmacsVersionIdentifier
+from ..utils import memoized
class MagitProject(EmacsGitProject):
@@ -20,9 +21,34 @@ class MagitProject(EmacsGitProject):
_project_git_repo = 'git://github.com/magit/magit.git'
_project_git_branches = ['maint', 'master', 'next']
- def getFactory(self, branch, combo):
+ _deps = [('mocker', 'git://github.com/sigma/mocker.el', 'master')]
+
+ @memoized
+ def getBasicFactory(self, branch):
+ factory = BuildFactory()
+ _emacs_prop = 'EMACS=%(slave/binaries/emacs:-emacs)s'
+ factory.addStep(
+ Git(repourl=self._project_git_repo, mode='copy',
+ branch=branch, logEnviron=False))
+ factory.addStep(
+ EmacsCompile(command=["make",
+ WithProperties(_emacs_prop),
+ "clean", "all"],
+ logEnviron=False))
+ return factory
+
+ @memoized
+ def getTestingFactory(self, branch):
factory = BuildFactory()
_emacs_prop = 'EMACS=%(slave/binaries/emacs:-emacs)s'
+ _eflags = '-L ../mocker'
+
+ for p, r, t in self._deps:
+ factory.addStep(
+ Git(repourl=r, branch=t,
+ workdir=p, logEnviron=False,
+ description=['updating %s' % (p)],
+ descriptionDone=['update %s' % (p)]))
factory.addStep(
Git(repourl=self._project_git_repo, mode='copy',
branch=branch, logEnviron=False))
@@ -31,4 +57,19 @@ def getFactory(self, branch, combo):
WithProperties(_emacs_prop),
"clean", "all"],
logEnviron=False))
+ factory.addStep(
+ EmacsTest(command=["make",
+ WithProperties(_emacs_prop),
+ "EFLAGS=%s" % (_eflags),
+ "test"],
+ logEnviron=False))
return factory
+
+ def getFactory(self, branch, combo):
+ if not EmacsVersionIdentifier(kind="gnu", version="24")(combo['emacs']):
+ return self.getBasicFactory(branch)
+
+ if branch == "maint":
+ return self.getBasicFactory(branch)
+
+ return self.getTestingFactory(branch)
View
@@ -0,0 +1,30 @@
+import functools
+
+class memoized(object):
+ """Decorator that caches a function's return value each time it is called.
+ If called later with the same arguments, the cached value is returned, and
+ not re-evaluated.
+ """
+ def __init__(self, func):
+ self.func = func
+ self.cache = {}
+
+ def __call__(self, *args):
+ try:
+ return self.cache[args]
+ except KeyError:
+ value = self.func(*args)
+ self.cache[args] = value
+ return value
+ except TypeError:
+ # uncachable -- for instance, passing a list as an argument.
+ # Better to not cache than to blow up entirely.
+ return self.func(*args)
+
+ def __repr__(self):
+ """Return the function's docstring."""
+ return self.func.__doc__
+
+ def __get__(self, obj, objtype):
+ """Support instance methods."""
+ return functools.partial(self.__call__, obj)

0 comments on commit b289498

Please sign in to comment.