23
23
import subprocess
24
24
import tempfile
25
25
import re
26
+ import logging
26
27
27
28
TEST_EXIT_PASSED = 0
28
29
TEST_EXIT_SKIPPED = 77
@@ -141,6 +142,7 @@ def main():
141
142
parser .add_argument ('--force' , '-f' , action = 'store_true' , help = 'run tests even on platforms where they are disabled by default (e.g. windows).' )
142
143
parser .add_argument ('--help' , '-h' , '-?' , action = 'store_true' , help = 'print help text and exit' )
143
144
parser .add_argument ('--jobs' , '-j' , type = int , default = 4 , help = 'how many test scripts to run in parallel. Default=4.' )
145
+ parser .add_argument ('--quiet' , '-q' , action = 'store_true' , help = 'only print results summary and failure logs' )
144
146
parser .add_argument ('--nozmq' , action = 'store_true' , help = 'do not run the zmq tests' )
145
147
args , unknown_args = parser .parse_known_args ()
146
148
@@ -152,6 +154,10 @@ def main():
152
154
config = configparser .ConfigParser ()
153
155
config .read_file (open (os .path .dirname (__file__ ) + "/config.ini" ))
154
156
157
+ # Set up logging
158
+ logging_level = logging .INFO if args .quiet else logging .DEBUG
159
+ logging .basicConfig (format = '%(message)s' , level = logging_level )
160
+
155
161
enable_wallet = config ["components" ].getboolean ("ENABLE_WALLET" )
156
162
enable_utils = config ["components" ].getboolean ("ENABLE_UTILS" )
157
163
enable_bitcoind = config ["components" ].getboolean ("ENABLE_BITCOIND" )
@@ -233,7 +239,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
233
239
if enable_coverage :
234
240
coverage = RPCCoverage ()
235
241
flags .append (coverage .flag )
236
- print ("Initializing coverage directory at %s\n " % coverage .dir )
242
+ logging . debug ("Initializing coverage directory at %s" % coverage .dir )
237
243
else :
238
244
coverage = None
239
245
@@ -249,16 +255,20 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
249
255
job_queue = TestHandler (jobs , tests_dir , test_list , flags )
250
256
251
257
max_len_name = len (max (test_list , key = len ))
252
- results = BOLD [1 ] + "%s | %s | %s\n \n " % ("TEST" .ljust (max_len_name ), "STATUS " , "DURATION" ) + BOLD [0 ]
258
+ results = " \n " + BOLD [1 ] + "%s | %s | %s\n \n " % ("TEST" .ljust (max_len_name ), "STATUS " , "DURATION" ) + BOLD [0 ]
253
259
for _ in range (len (test_list )):
254
260
(name , stdout , stderr , status , duration ) = job_queue .get_next ()
255
261
all_passed = all_passed and status != "Failed"
256
262
time_sum += duration
257
263
258
- print ('\n ' + BOLD [1 ] + name + BOLD [0 ] + ":" )
259
- print ('' if status == "Passed" else stdout + '\n ' , end = '' )
260
- print ('' if stderr == '' else 'stderr:\n ' + stderr + '\n ' , end = '' )
261
- print ("Status: %s%s%s, Duration: %s s\n " % (BOLD [1 ], status , BOLD [0 ], duration ))
264
+ if status == "Passed" :
265
+ logging .debug ("\n %s%s%s passed, Duration: %s s" % (BOLD [1 ], name , BOLD [0 ], duration ))
266
+ elif status == "Skipped" :
267
+ logging .debug ("\n %s%s%s skipped" % (BOLD [1 ], name , BOLD [0 ]))
268
+ else :
269
+ print ("\n %s%s%s failed, Duration: %s s\n " % (BOLD [1 ], name , BOLD [0 ], duration ))
270
+ print (BOLD [1 ] + 'stdout:\n ' + BOLD [0 ] + stdout + '\n ' )
271
+ print (BOLD [1 ] + 'stderr:\n ' + BOLD [0 ] + stderr + '\n ' )
262
272
263
273
results += "%s | %s | %s s\n " % (name .ljust (max_len_name ), status .ljust (7 ), duration )
264
274
@@ -269,7 +279,7 @@ def run_tests(test_list, src_dir, build_dir, exeext, jobs=1, enable_coverage=Fal
269
279
if coverage :
270
280
coverage .report_rpc_coverage ()
271
281
272
- print ("Cleaning up coverage data" )
282
+ logging . debug ("Cleaning up coverage data" )
273
283
coverage .cleanup ()
274
284
275
285
sys .exit (not all_passed )
0 commit comments