4 from buildbot.steps.source import SVN
5 from buildbot.steps.shell import ShellCommand
6 from buildbot.steps.transfer import FileDownload
8 from buildbot.status import builder
9 from buildbot.status.builder import SUCCESS,FAILURE, EXCEPTION,WARNINGS
11 from buildbot.process.properties import WithProperties
14 # Define a new builder status
15 # Configure return the exit code 77 when the target platform don't
16 # bear ucontext functionnality. In this case the CustomConfigure returns
17 # INCOMPATIBLE_PLATFORM.
20 CustomConfigure class for master-side representation of the
21 custom configure command. This class considers the error (exit code 77)
22 that occurs when the platform target don't bear ucontext functionnality.
24 class CustomConfigure(ShellCommand):
27 description = ["running configure"]
28 descriptionDone = [name]
31 # Override evaluateCommand method to handle the case of platform that
32 # don't support ucontext. The method returns sets self.incompatible
35 def evaluateCommand(self, cmd):
36 """Decide whether the command was SUCCESS, FAILURE or incompatible platform"""
41 self.incompatible = True
46 # Override getColor method. The method returns the text "blue" when platform is incompatible
48 def getColor(self, cmd, results):
49 assert results in (SUCCESS, WARNINGS, FAILURE)
50 if results == SUCCESS:
52 elif results == WARNINGS:
54 elif self.incompatible:
59 # Override getText method. The method calls describe method
60 # with the text "failed {incompatible platform}" when the platform
61 # don't support ucontext functionnality.
63 def getText(self, cmd, results):
64 if results == SUCCESS:
65 return self.describe(True) + ["Configure success"]
66 elif results == WARNINGS:
67 return self.describe(True) + ["warnings"]
68 elif self.incompatible:
69 return self.describe(True) + ["failed {incompatible platform}"]
71 return self.describe(True) + ["failed"]
73 def maybeGetText2(self, cmd, results):
74 if results == SUCCESS:
76 elif results == WARNINGS:
78 elif self.incompatible:
79 return ["incompatible platform"]
81 return self.describe(True) + ["failed"]
86 Cleanup the build dir, and setup a SVN revision in the waterfall afterward
88 class CleanupCommand(ShellCommand):
90 descriptionDone="cleanup"
91 command=["bash","-c","rm -rf * .svn"]
93 def maybeGetText2(self,cmd,results):
94 if self.build.getProperty("revision") == None:
95 return ["Missing svn revision"]
96 return ["SVN r%s" % self.build.getProperty("revision")]
99 Just like a plain SVN, but displays the current revision in the waterfall afterall
101 class CustomSVN(SVN):
102 def getText(self,cmd,results):
103 lines = cmd.logs['stdio'].getText()
104 r = re.search(' (\d+).',lines)
105 if results == SUCCESS and r:
106 return self.describe(True) + ["updated to %s" % r.group(1)]
107 elif results == SUCCESS:
108 return self.describe(True) + ["updated to some version"]
110 return self.describe(True) + ["failed"]
112 def maybeGetText2(self,cmd,results):
113 lines = cmd.logs['stdio'].getText()
114 r = re.search(' (\d+).',lines)
115 if results == SUCCESS and r:
116 return ["SVN r%s" % r.group(1)]
121 CustomCheck class for master-side representation of the checkall results.
122 This class stores and displays the amount of errors in the checks.
124 class CustomCheck(ShellCommand):
126 description = ["running checks"]
127 descriptionDone = [name]
130 # Override per step getText method.
131 def getText(self, cmd, results):
132 lines = cmd.logs['stdio'].getText().split("\n")
134 fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
135 re.compile('^XFAIL:')
136 xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
138 skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
139 re.compile('^XPASS:')
140 xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
142 passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
146 res += ("%d failed, " % fail)
148 res += ("%d skipped, " % skip)
150 res += ("%d unexpected success, " % xpass)
152 res += ("%d expected failure, " % xfail)
153 res += ("%d total" % (passed + fail + skip + xpass + xfail))
155 if results == SUCCESS:
156 return self.describe(True) + ["Success (%s)" % res]
157 elif results == WARNINGS:
158 return self.describe(True) + ["warnings"]
160 return self.describe(True) + ["failed strangly"]
162 return self.describe(True) + [res]
164 # Add some text to the top-column box
165 def getText2(self, cmd, results):
166 lines = cmd.logs['stdio'].getText().split("\n")
168 fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
169 re.compile('^XFAIL:')
170 xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
172 skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
173 re.compile('^XPASS:')
174 xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
176 passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
180 res += ("%d failed, " % fail)
182 res += ("%d skipped, " % skip)
184 res += ("%d unexpected success, " % xpass)
186 res += ("%d expected failure, " % xfail)
187 res += ("%d total" % (passed + fail + skip + xpass + xfail))
189 if results == SUCCESS:
190 return ["All tests ok (%s)" % res]
191 elif results == WARNINGS:
192 return ["Warnings (%s)" % res]
194 return ["Tests failed strangly"]