Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add a dist builder, which simply makes an archive to be distributed
[simgrid.git] / build / buildbot / extensions.py
1
2
3 import re        
4 from buildbot.process import step
5 from buildbot.process.step import ShellCommand, SVN
6 from buildbot.status import builder
7 from buildbot.status.builder import SUCCESS,FAILURE, EXCEPTION,WARNINGS
8
9 # Define a new builder status
10 # Configure return the exit code 77 when the target platform don't
11 # bear ucontext functionnality. In this case the CustomConfigure returns
12 # INCOMPATIBLE_PLATFORM.
13
14 """
15 CustomConfigure class for master-side representation of the
16 custom configure command. This class considers the error (exit code 77)
17 that occurs when the platform target don't bear ucontext functionnality.
18 """
19 class CustomConfigure(ShellCommand):
20
21     name = "configure"
22     description = ["running configure"]
23     descriptionDone = [name]
24     incompatible = False
25
26     # Override evaluateCommand method to handle the case of platform that 
27     # don't support ucontext. The method returns sets self.incompatible
28     # in this case.
29         
30     def evaluateCommand(self, cmd):
31         """Decide whether the command was SUCCESS, FAILURE or incompatible platform"""
32         
33         if cmd.rc == 0:
34                 return SUCCESS
35         elif cmd.rc == 77:
36                 self.incompatible = True
37                 return FAILURE
38         else:
39                 return FAILURE
40            
41      # Override getColor method. The method returns the text "blue" when platform is incompatible
42         
43     def getColor(self, cmd, results):
44         assert results in (SUCCESS, WARNINGS, FAILURE)
45         if results == SUCCESS:
46             return "green"
47         elif results == WARNINGS:
48             return "orange"
49         elif self.incompatible:
50             return "blue"
51         else:
52             return "red"
53             
54         # Override getText method. The method calls describe method
55         # with the text "failed {incompatible platform}" when the platform
56         # don't support ucontext functionnality.
57                
58     def getText(self, cmd, results):
59         if results == SUCCESS:
60             return self.describe(True) + ["Configure success"]
61         elif results == WARNINGS:
62             return self.describe(True) + ["warnings"]
63         elif self.incompatible:
64             return self.describe(True) + ["failed {incompatible platform}"]
65         else:
66             return self.describe(True) + ["failed"]
67             
68     def maybeGetText2(self, cmd, results):
69         if results == SUCCESS:
70             pass
71         elif results == WARNINGS:
72             pass
73         elif self.incompatible:
74             return ["incompatible platform"]
75         else:
76             return self.describe(True) + ["failed"]
77         return []
78
79
80
81 """
82 Just like a plain SVN, but displays the current revision in the waterfall afterall
83 """
84 class CustomSVN(SVN):        
85    def getText(self,cmd,results):
86        lines = cmd.logs['stdio'].getText()
87        r = re.search(' (\d+).',lines)
88        if results == SUCCESS and r:
89             return self.describe(True) + ["updated to %s" % r.group(1)]
90        elif results == SUCCESS:
91             return self.describe(True) + ["updated to some version"]
92        else:
93             return self.describe(True) + ["failed"]
94         
95    def maybeGetText2(self,cmd,results):
96        lines = cmd.logs['stdio'].getText()
97        r = re.search(' (\d+).',lines)
98        if results == SUCCESS and r:
99            return ["SVN revision %s" % r.group(1)]
100        else:
101            return []
102               
103 """
104 CustomCheck class for master-side representation of the checkall results.
105 This class stores and displays the amount of errors in the checks.
106 """
107 class CustomCheck(ShellCommand):
108     name = "check"
109     description = ["running checks"]
110     descriptionDone = [name]
111
112             
113    # Override per step getText method.         
114     def getText(self, cmd, results):
115        lines = cmd.logs['stdio'].getText().split("\n")
116        re.compile('^FAIL:')
117        fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
118        re.compile('^XFAIL:')
119        xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
120        re.compile('^SKIP:')
121        skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
122        re.compile('^XPASS:')
123        xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
124        re.compile('^PASS:')
125        passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
126        
127        res = ""
128        if fail != 0:
129            res += ("%d failed, " % fail)
130        if skip != 0:
131            res += ("%d skipped, " % skip)
132        if xpass != 0:
133            res += ("%d unexpected success, " % xpass)
134        if xfail != 0:
135            res += ("%d expected failure, " % xfail)
136        res += ("%d total" % (passed + fail + skip + xpass + xfail))
137               
138        if results == SUCCESS:
139             return self.describe(True) + ["Success (%s)" % res]
140        elif results == WARNINGS:
141             return self.describe(True) + ["warnings"]
142        elif fail == 0:
143             return self.describe(True) + ["failed strangly"]
144        else:
145             return self.describe(True) + [res]
146                 
147    # Add some text to the top-column box
148     def getText2(self, cmd, results):
149        lines = cmd.logs['stdio'].getText().split("\n")
150        re.compile('^FAIL:')
151        fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
152        re.compile('^XFAIL:')
153        xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
154        re.compile('^SKIP:')
155        skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
156        re.compile('^XPASS:')
157        xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
158        re.compile('^PASS:')
159        passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
160        
161        res = ""
162        if fail != 0:
163            res += ("%d failed, " % fail)
164        if skip != 0:
165            res += ("%d skipped, " % skip)
166        if xpass != 0:
167            res += ("%d unexpected success, " % xpass)
168        if xfail != 0:
169            res += ("%d expected failure, " % xfail)
170        res += ("%d total" % (passed + fail + skip + xpass + xfail))
171               
172        if results == SUCCESS:
173             return ["All tests ok (%s)" % res]
174        elif results == WARNINGS:
175             return ["Warnings (%s)" % res]
176        elif fail == 0:
177             return ["Tests failed strangly"]
178        else:
179             return [res]