1
0
Fork 0
mirror of https://github.com/anrieff/libcpuid synced 2025-06-07 00:51:40 +00:00

Tests: fix run_tests.py for filenames containing dots

This commit is contained in:
The Tumultuous Unicorn Of Darkness 2025-05-01 21:03:18 +02:00
parent 632bd475b1
commit 9608fab785
No known key found for this signature in database
GPG key ID: 1E55EE2EFF18BC1A

View file

@ -39,13 +39,9 @@ def fmt_error(err):
def fixFile(filename, input_lines, output_lines): def fixFile(filename, input_lines, output_lines):
pfilename = Path(filename) pfilename = Path(filename)
if len(pfilename.suffixes) >= 2: if pfilename.suffixes[-1] == ".xz":
# Compressed file # XZ compressed file
if pfilename.suffixes[1] == ".xz": f = lzma.open(pfilename, "wt")
f = lzma.open(pfilename, "wt")
else:
print(f"Cannot fix {pfilename.name} because {''.join(pfilename.suffixes[1:])} is not supported")
return
else: else:
# Plain text file # Plain text file
f = open(pfilename, "wt") f = open(pfilename, "wt")
@ -153,7 +149,7 @@ for input_test_file in args.input_test_files:
if Path(input_test_file).is_dir(): if Path(input_test_file).is_dir():
# gather all *.test files from subdirs amd, intel and cie: # gather all *.test files from subdirs amd, intel and cie:
for dirpath, dirnames, filenames in os.walk(input_test_file): for dirpath, dirnames, filenames in os.walk(input_test_file):
filelist += [PurePath(dirpath).joinpath(fn) for fn in filenames if Path(fn).suffixes[0] == ".test"] filelist += [PurePath(dirpath).joinpath(fn) for fn in filenames if ".test" in Path(fn).suffixes]
else: else:
filelist.append(input_test_file) filelist.append(input_test_file)
@ -166,13 +162,9 @@ for test_file_name_raw in filelist:
current_input = [] current_input = []
current_output = [] current_output = []
build_output = False build_output = False
if len(test_file_name.suffixes) >= 2: if test_file_name.suffixes[-1] == ".xz":
# Compressed file # XZ compressed file
if test_file_name.suffixes[1] == ".xz": f = lzma.open(test_file_name, "rt")
f = lzma.open(test_file_name, "rt")
else:
print(f"Test [{test_file_name.name}]: skipped because {''.join(test_file_name.suffixes[1:])} is not supported")
continue
else: else:
# Plain text file # Plain text file
f = open(test_file_name, "rt") f = open(test_file_name, "rt")