14
14
15
15
class Tests :
16
16
def __init__ (self , url , environment ):
17
+ self .retval = 0
17
18
self .url = url
18
19
self .environment = os .path .abspath (environment )
19
20
self .
email = os .
getenv (
'EMAIL' ,
'[email protected] ' )
@@ -47,10 +48,16 @@ def run_command(self, command):
47
48
return subprocess .call (command , shell = True , executable = SHELL )
48
49
49
50
def send_mail_no_logs (self , identifier ):
51
+ if self .url == 'local' :
52
+ return
53
+
50
54
command = ['mail' , '-s' , '"Selenium Tests: {identifier} Failed To Run" {email} <<< "Something went wrong with {identifier} tests. Please check the logs."' .format (identifier = identifier , email = self .email )]
51
55
self .run_command (command )
52
56
53
57
def send_mail_with_logs (self , identifier ):
58
+ if self .url == 'local' :
59
+ return
60
+
54
61
default_tests_dir = os .path .normpath (os .path .join (os .path .dirname (__file__ ), '..' ))
55
62
root_dir = os .getenv ('ROOTDIR' , default_tests_dir )
56
63
@@ -88,31 +95,41 @@ def common(self, test, identifier='common'):
88
95
command = self .create_command (test_directory , '--plugin' )
89
96
retval = self .run_command (command )
90
97
if retval != 0 :
98
+ self .retval = retval
91
99
self .send_mail_no_logs (identifier )
92
100
93
101
def libraries (self , identifier = 'libraries_fetch' ):
94
102
command = self .create_command ('libraries_fetch' , '-F' , '--plugin' )
95
- self .run_command (command )
103
+ retval = self .run_command (command )
104
+ if retval != 0 :
105
+ self .retval = retval
96
106
self .send_mail_with_logs (identifier )
97
107
98
108
def examples (self , identifier = 'libraries_test' ):
99
109
command = self .create_command ('libraries' , '-F' , '--plugin' )
100
- self .run_command (command )
110
+ retval = self .run_command (command )
111
+ if retval != 0 :
112
+ self .retval = retval
101
113
self .send_mail_with_logs (identifier )
102
114
103
115
def sketches (self , identifier = 'cb_compile_tester' ):
104
116
command = self .create_command ('compile_tester' , '-F' , '--plugin' )
105
- self .run_command (command )
117
+ retval = self .run_command (command )
118
+ if retval != 0 :
119
+ self .retval = retval
106
120
self .send_mail_with_logs (identifier )
107
121
108
122
def compile (self , libraries ):
109
123
command = self .create_command ('target_libraries' , '-F' , '--plugin' , '--libraries={}' .format (libraries ))
110
- self .run_command (command )
124
+ retval = self .run_command (command )
125
+ if retval != 0 :
126
+ self .retval = retval
111
127
112
128
def noplugin (self , identifier = 'noplugin' ):
113
129
command = self .create_command ('noplugin' )
114
130
retval = self .run_command (command )
115
131
if retval != 0 :
132
+ self .retval = retval
116
133
self .send_mail_no_logs (identifier )
117
134
118
135
def walkthrough (self , identifier = 'walkthrough' ):
@@ -127,15 +144,20 @@ def walkthrough(self, identifier='walkthrough'):
127
144
128
145
retval = max (retvals )
129
146
if retval != 0 :
147
+ self .retval = retval
130
148
self .send_mail_no_logs (identifier )
131
149
132
150
def staging (self ):
133
151
command = self .create_command ('compile_tester' , '-F' , '--plugin' )
134
- self .run_command (command )
152
+ retval = self .run_command (command )
153
+ if retval != 0 :
154
+ self .retval = retval
135
155
136
156
def delete (self ):
137
157
command = self .create_command ('delete_sketches' )
138
- self .run_command (command )
158
+ retval = self .run_command (command )
159
+ if retval != 0 :
160
+ self .retval = retval
139
161
140
162
OPERATIONS = {
141
163
'common' :'\t Test site common functionality' ,
@@ -275,5 +297,8 @@ def main():
275
297
tests = Tests (target , config )
276
298
tests .run (operation , test = test , libraries = libraries )
277
299
300
+ print ('Tests exit code:' , tests .retval )
301
+ sys .exit (tests .retval )
302
+
278
303
if __name__ == '__main__' :
279
304
main ()
0 commit comments