From ca50ff42ead94244f6b085726248b2b25d76a6c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20=C5=9Aliwak?= Date: Thu, 28 Oct 2021 18:42:35 +0200 Subject: [PATCH] [TMP] Helper script for splitting the list of test cases into batches --- ...ltest_test_case_names_from_list_content.py | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 scripts/isoltest_test_case_names_from_list_content.py diff --git a/scripts/isoltest_test_case_names_from_list_content.py b/scripts/isoltest_test_case_names_from_list_content.py new file mode 100644 index 000000000..b6ce5b67f --- /dev/null +++ b/scripts/isoltest_test_case_names_from_list_content.py @@ -0,0 +1,56 @@ +from copy import copy +import math +import re +import sys + +batch_id = int(sys.argv[1]) +batch_count = int(sys.argv[2]) +assert batch_id >= 1 + +if batch_id > batch_count: + sys.exit(0) + +last_indent_level = 0 +prefix = [""] +tests = [] +suites = [] +for line in sys.stdin: + match = re.match(r'^( *)([^*]+)\*$', line) + if match is None: + print("No match") + else: + indent = match[1] + name = match[2] + + assert len(indent) % 4 == 0 + indent_level = int(len(indent) / 4) + + if indent_level > last_indent_level: + suites.append(copy(prefix)) + prefix.append(name) + else: + assert len(prefix) > 0 + if prefix[0] != "": + tests.append(copy(prefix)) + + for i in range(last_indent_level - indent_level + 1): + prefix.pop() + prefix.append(name) + + last_indent_level = indent_level + +if len(prefix) > 0: + assert prefix[0] != "" + tests.append(copy(prefix)) + +start = math.ceil(len(tests) / batch_count) * (batch_id - 1) +end = math.ceil(len(tests) / batch_count) * batch_id + +if start < len(tests): + print( + ':'.join([ + '/'.join(prefix) + for i, prefix in enumerate(tests) + if start <= i < min(end, len(tests)) + ]) + )