comparison tests/run-tests.py @ 34969:d600bda4a3e1

run-tests: allow automatic test discovery when providing folder as argument Currently `run-tests.py` automatically discovers test only in the current directory if no argument is provided. This patch makes it possible to pass a number of tests and folders as arguments.
author Matthieu Laneuville <matthieu.laneuville@octobus.net>
date Thu, 19 Oct 2017 23:13:57 +0900
parents d8c2db6167b3
children 57d56f603f70
comparison
equal deleted inserted replaced
34968:3649c3f2cd90 34969:d600bda4a3e1
2508 stdout, stderr = proc.communicate() 2508 stdout, stderr = proc.communicate()
2509 args = stdout.strip(b'\0').split(b'\0') 2509 args = stdout.strip(b'\0').split(b'\0')
2510 else: 2510 else:
2511 args = os.listdir(b'.') 2511 args = os.listdir(b'.')
2512 2512
2513 expanded_args = []
2514 for arg in args:
2515 if os.path.isdir(arg):
2516 if not arg.endswith(b'/'):
2517 arg += b'/'
2518 expanded_args.extend([arg + a for a in os.listdir(arg)])
2519 else:
2520 expanded_args.append(arg)
2521 args = expanded_args
2522
2513 tests = [] 2523 tests = []
2514 for t in args: 2524 for t in args:
2515 if not (os.path.basename(t).startswith(b'test-') 2525 if not (os.path.basename(t).startswith(b'test-')
2516 and (t.endswith(b'.py') or t.endswith(b'.t'))): 2526 and (t.endswith(b'.py') or t.endswith(b'.t'))):
2517 continue 2527 continue