-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
python is faster than bash (why? - to investigate)
- Loading branch information
1 parent
853af64
commit 2ae5d5c
Showing
2 changed files
with
25 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,31 @@ | ||
import os | ||
import sys | ||
import re | ||
import sys | ||
|
||
test_folder = sys.argv[1] | ||
|
||
files = [f.split('.')[0] for f in os.listdir(f'tests/{test_folder}')] | ||
tests_dict = dict() | ||
tests_dict = {} | ||
|
||
for root, dirs, files in os.walk('tests'): | ||
for file in files: | ||
if file.endswith('.in') and root.endswith(test_folder): | ||
file_path = os.path.join(root, file) | ||
src_file_path = os.path.dirname(file_path) | ||
file_name = os.path.basename(file) | ||
base_name = os.path.splitext(file_name)[0] | ||
file_number = int(re.findall(r'\d+$', base_name)[0]) | ||
name = re.sub(r'\d+$', '', base_name) | ||
full_name = os.path.join(src_file_path, name) | ||
if full_name in tests_dict: | ||
if file_number > tests_dict[full_name]: | ||
tests_dict[full_name] = file_number | ||
else: | ||
tests_dict[full_name] = file_number | ||
|
||
for file in files: | ||
file_number = re.findall(r'\d+', file)[-1] | ||
file_name = file[:len(file) - len(file_number)] | ||
if file_name in tests_dict.keys(): | ||
tests_dict[file_name] = max(tests_dict[file_name], int(file_number)) | ||
else: | ||
tests_dict[file_name] = int(file_number) | ||
output_env_var = "" | ||
for test_name in tests_dict: | ||
output_env_var += f"{test_name}:{tests_dict[test_name]}," | ||
|
||
output_env_var = '' | ||
for test_name, tests_number in tests_dict.items(): | ||
output_env_var += test_name + ':' + str(tests_number) + ',' | ||
output_env_var = output_env_var.rstrip(output_env_var[-1]) | ||
output_env_var = output_env_var[:-1] | ||
|
||
print(output_env_var) | ||
print(output_env_var) |