Skip to content

Commit

Permalink
Fix file_target._md5 for pathlib for python 3.10 (close #1539)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoPeng committed Feb 16, 2024
1 parent 095bd3a commit 2c976c7
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions test/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def test_failed(test_names, return_code):

if __name__ == '__main__':
parser = argparse.ArgumentParser('run_tests')
parser.add_argument('tests', nargs='*', help='Tests that will be executed instead of gathering all tests.')
parser.add_argument('-b', '--batch', default=5, type=int, help='Group tests')
parser.add_argument(
'-l',
Expand All @@ -78,33 +79,36 @@ def test_failed(test_names, return_code):
parser.add_argument('-x', '--exitfirst', help='Stop when one test fails')
args = parser.parse_args()

print('Collecting tests')
all_tests = get_testcases()
print(f'{len(all_tests)} tests are collected.')
if args.tests:
all_tests = args.tests
else:
print('Collecting tests')
all_tests = get_testcases()
print(f'{len(all_tests)} tests are collected.')

if args.lastfailed is not None:
if not os.path.isfile(LOGFILE):
sys.exit(f'Log file {LOGFILE} does not exists.')
test_results = {}
with open(LOGFILE) as fl:
for line in fl:
if not line.strip():
continue
try:
fields = line.split()
if len(fields) >= 2:
tst = fields[-2]
res = fields[-1].strip()
else:
tst = fields[-1]
res = 'FAILED'
except Exception:
print(f'Invalid log line: {line}')
test_results[tst] = res.strip()
all_tests = [x for x, y in test_results.items() if y == 'FAILED' and x in all_tests]
# if args.lastfailed != 0:
# all_tests = all_tests[-args.lastfailed:]
print(f'Running {len(all_tests)} failed tests.')
if args.lastfailed is not None:
if not os.path.isfile(LOGFILE):
sys.exit(f'Log file {LOGFILE} does not exists.')
test_results = {}
with open(LOGFILE) as fl:
for line in fl:
if not line.strip():
continue
try:
fields = line.split()
if len(fields) >= 2:
tst = fields[-2]
res = fields[-1].strip()
else:
tst = fields[-1]
res = 'FAILED'
except Exception:
print(f'Invalid log line: {line}')
test_results[tst] = res.strip()
all_tests = [x for x, y in test_results.items() if y == 'FAILED' and x in all_tests]
# if args.lastfailed != 0:
# all_tests = all_tests[-args.lastfailed:]
print(f'Running {len(all_tests)} failed tests.')

failed_tests = []
nbatch = len(all_tests) // args.batch + 1
Expand Down

0 comments on commit 2c976c7

Please sign in to comment.