1414
1515class Tests :
1616 def __init__ (self , url , environment ):
17+ self .retval = 0
1718 self .url = url
1819 self .environment = os .path .abspath (environment )
1920 self .email = os .getenv ('EMAIL' , 'void@mail.0' )
@@ -47,10 +48,16 @@ def run_command(self, command):
4748 return subprocess .call (command , shell = True , executable = SHELL )
4849
4950 def send_mail_no_logs (self , identifier ):
51+ if self .url == 'local' :
52+ return
53+
5054 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 )]
5155 self .run_command (command )
5256
5357 def send_mail_with_logs (self , identifier ):
58+ if self .url == 'local' :
59+ return
60+
5461 default_tests_dir = os .path .normpath (os .path .join (os .path .dirname (__file__ ), '..' ))
5562 root_dir = os .getenv ('ROOTDIR' , default_tests_dir )
5663
@@ -88,31 +95,41 @@ def common(self, test, identifier='common'):
8895 command = self .create_command (test_directory , '--plugin' )
8996 retval = self .run_command (command )
9097 if retval != 0 :
98+ self .retval = retval
9199 self .send_mail_no_logs (identifier )
92100
93101 def libraries (self , identifier = 'libraries_fetch' ):
94102 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
96106 self .send_mail_with_logs (identifier )
97107
98108 def examples (self , identifier = 'libraries_test' ):
99109 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
101113 self .send_mail_with_logs (identifier )
102114
103115 def sketches (self , identifier = 'cb_compile_tester' ):
104116 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
106120 self .send_mail_with_logs (identifier )
107121
108122 def compile (self , libraries ):
109123 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
111127
112128 def noplugin (self , identifier = 'noplugin' ):
113129 command = self .create_command ('noplugin' )
114130 retval = self .run_command (command )
115131 if retval != 0 :
132+ self .retval = retval
116133 self .send_mail_no_logs (identifier )
117134
118135 def walkthrough (self , identifier = 'walkthrough' ):
@@ -127,15 +144,20 @@ def walkthrough(self, identifier='walkthrough'):
127144
128145 retval = max (retvals )
129146 if retval != 0 :
147+ self .retval = retval
130148 self .send_mail_no_logs (identifier )
131149
132150 def staging (self ):
133151 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
135155
136156 def delete (self ):
137157 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
139161
140162OPERATIONS = {
141163 'common' :'\t Test site common functionality' ,
@@ -275,5 +297,8 @@ def main():
275297 tests = Tests (target , config )
276298 tests .run (operation , test = test , libraries = libraries )
277299
300+ print ('Tests exit code:' , tests .retval )
301+ sys .exit (tests .retval )
302+
278303if __name__ == '__main__' :
279304 main ()
0 commit comments