Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

tweak magit builds

  • Loading branch information...
commit b2894987786cfc4f6e9ac78a6e4cf78adbb037af 1 parent 6532209
Yann Hodique authored March 29, 2012
9  emacs/projects/_base.py
@@ -64,18 +64,19 @@ def getAssignments(self):
64 64
         assignments = []
65 65
 
66 66
         for combo in product(*values):
67  
-            combo_tag = dict(zip(keys, combo))
  67
+            combo_tag = {}
68 68
             slaves = []
69 69
             for slave in self._slaves:
70 70
                 fits = True
71  
-                for key, val in zip(keys, combo):
  71
+                for key, expected in zip(keys, combo):
72 72
                     if not slave.properties.has_key("slave/features/" + key):
73 73
                         fits = False
74 74
                         break
75  
-                    if not self.validateFeature(
76  
-                        slave.properties['slave/features/' + key], val):
  75
+                    proposed = slave.properties['slave/features/' + key]
  76
+                    if not self.validateFeature(proposed, expected):
77 77
                         fits = False
78 78
                         break
  79
+                    combo_tag[key] = proposed
79 80
                 if fits:
80 81
                     slaves.append(slave.slavename)
81 82
             if slaves:
45  emacs/projects/magit.py
@@ -4,8 +4,9 @@
4 4
 from buildbot.steps.source import Git
5 5
 from buildbot.process.properties import WithProperties
6 6
 
7  
-from ..steps import EmacsCompile
  7
+from ..steps import EmacsCompile, EmacsTest
8 8
 from ..versions import EmacsVersionIdentifier
  9
+from ..utils import memoized
9 10
 
10 11
 class MagitProject(EmacsGitProject):
11 12
 
@@ -20,9 +21,34 @@ class MagitProject(EmacsGitProject):
20 21
     _project_git_repo = 'git://github.com/magit/magit.git'
21 22
     _project_git_branches = ['maint', 'master', 'next']
22 23
 
23  
-    def getFactory(self, branch, combo):
  24
+    _deps = [('mocker', 'git://github.com/sigma/mocker.el', 'master')]
  25
+
  26
+    @memoized
  27
+    def getBasicFactory(self, branch):
  28
+        factory = BuildFactory()
  29
+        _emacs_prop = 'EMACS=%(slave/binaries/emacs:-emacs)s'
  30
+        factory.addStep(
  31
+            Git(repourl=self._project_git_repo, mode='copy',
  32
+                branch=branch, logEnviron=False))
  33
+        factory.addStep(
  34
+            EmacsCompile(command=["make",
  35
+                                  WithProperties(_emacs_prop),
  36
+                                  "clean", "all"],
  37
+                         logEnviron=False))
  38
+        return factory
  39
+
  40
+    @memoized
  41
+    def getTestingFactory(self, branch):
24 42
         factory = BuildFactory()
25 43
         _emacs_prop = 'EMACS=%(slave/binaries/emacs:-emacs)s'
  44
+        _eflags = '-L ../mocker'
  45
+
  46
+        for p, r, t in self._deps:
  47
+            factory.addStep(
  48
+                Git(repourl=r, branch=t,
  49
+                    workdir=p, logEnviron=False,
  50
+                    description=['updating %s' % (p)],
  51
+                    descriptionDone=['update %s' % (p)]))
26 52
         factory.addStep(
27 53
             Git(repourl=self._project_git_repo, mode='copy',
28 54
                 branch=branch, logEnviron=False))
@@ -31,4 +57,19 @@ def getFactory(self, branch, combo):
31 57
                                   WithProperties(_emacs_prop),
32 58
                                   "clean", "all"],
33 59
                          logEnviron=False))
  60
+        factory.addStep(
  61
+            EmacsTest(command=["make",
  62
+                               WithProperties(_emacs_prop),
  63
+                               "EFLAGS=%s" % (_eflags),
  64
+                               "test"],
  65
+                      logEnviron=False))
34 66
         return factory
  67
+
  68
+    def getFactory(self, branch, combo):
  69
+        if not EmacsVersionIdentifier(kind="gnu", version="24")(combo['emacs']):
  70
+            return self.getBasicFactory(branch)
  71
+
  72
+        if branch == "maint":
  73
+            return self.getBasicFactory(branch)
  74
+
  75
+        return self.getTestingFactory(branch)
30  emacs/utils.py
... ...
@@ -0,0 +1,30 @@
  1
+import functools
  2
+
  3
+class memoized(object):
  4
+    """Decorator that caches a function's return value each time it is called.
  5
+    If called later with the same arguments, the cached value is returned, and
  6
+    not re-evaluated.
  7
+    """
  8
+    def __init__(self, func):
  9
+        self.func = func
  10
+        self.cache = {}
  11
+
  12
+    def __call__(self, *args):
  13
+        try:
  14
+            return self.cache[args]
  15
+        except KeyError:
  16
+            value = self.func(*args)
  17
+            self.cache[args] = value
  18
+            return value
  19
+        except TypeError:
  20
+            # uncachable -- for instance, passing a list as an argument.
  21
+            # Better to not cache than to blow up entirely.
  22
+            return self.func(*args)
  23
+
  24
+    def __repr__(self):
  25
+        """Return the function's docstring."""
  26
+        return self.func.__doc__
  27
+
  28
+    def __get__(self, obj, objtype):
  29
+        """Support instance methods."""
  30
+        return functools.partial(self.__call__, obj)

0 notes on commit b289498

Please sign in to comment.
Something went wrong with that request. Please try again.