Logo AND Algorithmique Numérique Distribuée

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