Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
80e9347535d5057b67985b5be046d0dbbf3737b1
[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
69
70
71 """
72 Just like a plain SVN, but displays the current revision in the waterfall afterall
73 """
74 class CustomSVN(SVN):        
75    def getText(self,cmd,results):
76        lines = cmd.logs['stdio'].getText()
77        r = re.search(' (\d+).',lines)
78        if results == SUCCESS and r:
79             return self.describe(True) + ["updated to %s" % r.group(1)]
80        elif results == SUCCESS:
81             return self.describe(True) + ["updated to some version"]
82        else:
83             return self.describe(True) + ["failed"]             
84               
85 """
86 CustomCheck class for master-side representation of the checkall results.
87 This class stores and displays the amount of errors in the checks.
88 """
89 class CustomCheck(ShellCommand):
90     name = "check"
91     description = ["running checks"]
92     descriptionDone = [name]
93
94             
95    # Override getText method.          
96     def getText(self, cmd, results):
97        lines = cmd.logs['stdio'].getText().split("\n")
98        re.compile('^FAIL:')
99        fail = len( filter(lambda line: re.search('^FAIL:', line), lines) )
100        re.compile('^XFAIL:')
101        xfail = len( filter(lambda line: re.search('^XFAIL:', line), lines) )
102        re.compile('^SKIP:')
103        skip = len( filter(lambda line: re.search('^SKIP:', line), lines) )
104        re.compile('^XPASS:')
105        xpass = len( filter(lambda line: re.search('^XPASS:', line), lines) )
106        re.compile('^PASS:')
107        passed = len( filter(lambda line: re.search('^PASS:', line), lines) )
108        
109        res = ""
110        if fail != 0:
111            res += "%d failed, " % fail
112        if skip != 0:
113            res += "%d skipped, " % skip
114        if xpass != 0:
115            res += "%d unexpected success, " % xpass
116        if xfail != 0:
117            res += "%d expected failure, " % xfail
118        res += "%d total" % (passed + fail + skip + xpass + xfail)
119               
120        if results == SUCCESS:
121             return self.describe(True) + ["Success (%s)" % res]
122        elif results == WARNINGS:
123             return self.describe(True) + ["warnings"]
124        elif fail == 0:
125             return self.describe(True) + ["failed strangly"]
126        else:
127             return self.describe(True) + [res]
128