1
+ import difflib
2
+ import filecmp
3
+ import gevent
1
4
import os
5
+ import pprint
6
+ import pytap13
2
7
import re
8
+ import shutil
3
9
import sys
4
10
import time
5
- import filecmp
6
- import difflib
7
11
import traceback
8
- import gevent
9
- import pytap13
10
- import pprint
11
- import shutil
12
12
from functools import partial
13
13
14
14
try :
17
17
from StringIO import StringIO
18
18
19
19
import lib
20
- from lib .utils import non_empty_valgrind_logs , print_tail_n
21
20
from lib .colorer import color_stdout
21
+ from lib .utils import non_empty_valgrind_logs
22
+ from lib .utils import print_tail_n
22
23
23
24
24
25
class TestExecutionError (OSError ):
@@ -37,7 +38,10 @@ def _run(self, *args, **kwargs):
37
38
self .callable (* self .callable_args , ** self .callable_kwargs )
38
39
39
40
def __repr__ (self ):
40
- return "<TestRunGreenlet at %s info='%s'>" % (hex (id (self )), getattr (self , "info" , None ))
41
+ return "<TestRunGreenlet at {0} info='{1}'>" .format (
42
+ hex (id (self )),
43
+ getattr (self , "info" , None )
44
+ )
41
45
42
46
43
47
class FilteredStream :
@@ -134,7 +138,9 @@ def id(self):
134
138
135
139
def passed (self ):
136
140
"""Return true if this test was run successfully."""
137
- return self .is_executed and self .is_executed_ok and self .is_equal_result
141
+ return (self .is_executed and
142
+ self .is_executed_ok and
143
+ self .is_equal_result )
138
144
139
145
def execute (self , server ):
140
146
# Note: don't forget to set 'server.current_test = self' in
@@ -180,8 +186,9 @@ def run(self, server):
180
186
if e .__class__ .__name__ == 'TarantoolStartError' :
181
187
# worker should stop
182
188
raise
183
- color_stdout ('\n Test.run() received the following error:\n ' +
184
- traceback .format_exc () + '\n ' , schema = 'error' )
189
+ color_stdout ('\n Test.run() received the following error:\n '
190
+ '{0}\n ' .format (traceback .format_exc ()),
191
+ schema = 'error' )
185
192
diagnostics = str (e )
186
193
finally :
187
194
if sys .stdout and sys .stdout != save_stdout :
@@ -193,7 +200,8 @@ def run(self, server):
193
200
is_tap = False
194
201
if not self .skip :
195
202
if self .is_executed_ok and os .path .isfile (self .result ):
196
- self .is_equal_result = filecmp .cmp (self .result , self .tmp_result )
203
+ self .is_equal_result = filecmp .cmp (self .result ,
204
+ self .tmp_result )
197
205
elif self .is_executed_ok :
198
206
if lib .Options ().args .is_verbose :
199
207
color_stdout ('\n ' )
@@ -216,12 +224,15 @@ def run(self, server):
216
224
color_stdout ("[ skip ]\n " , schema = 'test_skip' )
217
225
if os .path .exists (self .tmp_result ):
218
226
os .remove (self .tmp_result )
219
- elif self .is_executed_ok and self .is_equal_result and self .is_valgrind_clean :
227
+ elif (self .is_executed_ok and
228
+ self .is_equal_result and
229
+ self .is_valgrind_clean ):
220
230
short_status = 'pass'
221
231
color_stdout ("[ pass ]\n " , schema = 'test_pass' )
222
232
if os .path .exists (self .tmp_result ):
223
233
os .remove (self .tmp_result )
224
- elif (self .is_executed_ok and not self .is_equal_result and not
234
+ elif (self .is_executed_ok and not
235
+ self .is_equal_result and not
225
236
os .path .isfile (self .result )) and not is_tap :
226
237
shutil .copy (self .tmp_result , self .result )
227
238
short_status = 'new'
@@ -234,9 +245,11 @@ def run(self, server):
234
245
where = ""
235
246
if not self .is_crash_reported and not self .is_executed_ok :
236
247
self .print_diagnostics (self .reject ,
237
- "Test failed! Output from reject file {}:\n " .format (self .reject ))
248
+ "Test failed! Output from reject file "
249
+ "{0}:\n " .format (self .reject ))
238
250
server .print_log (15 )
239
- where = ": test execution aborted, reason '{0}'" .format (diagnostics )
251
+ where = ": test execution aborted, reason " \
252
+ "'{0}'" .format (diagnostics )
240
253
elif not self .is_crash_reported and not self .is_equal_result :
241
254
self .print_unidiff ()
242
255
server .print_log (15 )
@@ -245,7 +258,8 @@ def run(self, server):
245
258
os .remove (self .reject )
246
259
for log_file in non_empty_logs :
247
260
self .print_diagnostics (log_file ,
248
- "Test failed! Output from log file {}:\n " .format (log_file ))
261
+ "Test failed! Output from log file "
262
+ "{0}:\n " .format (log_file ))
249
263
where = ": there were warnings in the valgrind log file(s)"
250
264
return short_status
251
265
@@ -261,7 +275,8 @@ def print_unidiff(self):
261
275
to establish the cause of a failure when .test differs
262
276
from .result."""
263
277
264
- color_stdout ("\n Test failed! Result content mismatch:\n " , schema = 'error' )
278
+ color_stdout ("\n Test failed! Result content mismatch:\n " ,
279
+ schema = 'error' )
265
280
with open (self .result , "r" ) as result :
266
281
with open (self .reject , "r" ) as reject :
267
282
result_time = time .ctime (os .stat (self .result ).st_mtime )
@@ -306,7 +321,8 @@ def tap_parse_print_yaml(self, yml):
306
321
def check_tap_output (self ):
307
322
""" Returns is_tap, is_ok """
308
323
if not os .path .isfile (self .tmp_result ):
309
- color_stdout ('\n Cannot find %s\n ' % self .tmp_result , schema = 'error' )
324
+ color_stdout ('\n Cannot find %s\n ' % self .tmp_result ,
325
+ schema = 'error' )
310
326
self .is_crash_reported = True
311
327
return False
312
328
with open (self .tmp_result , 'r' ) as f :
@@ -315,7 +331,8 @@ def check_tap_output(self):
315
331
try :
316
332
tap .parse (content )
317
333
except ValueError as e :
318
- color_stdout ('\n TAP13 parse failed: %s\n ' % str (e ), schema = 'error' )
334
+ color_stdout ('\n TAP13 parse failed: %s\n ' % str (e ),
335
+ schema = 'error' )
319
336
self .is_crash_reported = True
320
337
return False , False
321
338
is_ok = True
@@ -334,6 +351,7 @@ def check_tap_output(self):
334
351
self .tap_parse_print_yaml (test_case .yaml )
335
352
is_ok = False
336
353
if not is_ok :
337
- color_stdout ('Rejected result file: %s\n ' % self .reject , schema = 'test_var' )
354
+ color_stdout ('Rejected result file: %s\n ' % self .reject ,
355
+ schema = 'test_var' )
338
356
self .is_crash_reported = True
339
357
return True , is_ok
0 commit comments