Skip to content

Commit 32d1e19

Browse files
committed
Different approach
1 parent 4ec876a commit 32d1e19

6 files changed

+1312
-1305
lines changed
+2-26
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,11 @@
1-
import itertools
21
from pathlib import Path
32
import json
4-
import re
5-
6-
7-
def get_test_functions(tests_path):
8-
test_functions_regex = re.compile(r"^def (test_[a-zA-Z_]*)\(")
9-
test_functions = []
10-
for test_file in tests_path.glob("test_*.py"):
11-
12-
for line in test_file.read_text().splitlines():
13-
if match := test_functions_regex.match(line):
14-
test_functions.append(f"{test_file}::{match.group(1)}")
15-
return test_functions
163

174

185
if __name__ == "__main__":
196
import sys
207

218
tests_path = sys.argv[1]
22-
test_functions = get_test_functions(Path(tests_path))
23-
24-
# We split the test functions in 80 different lists because the maximum jobs
25-
# that can be run on Github Workflows generated by the matrix syntax is 256.
26-
# Since we run all tests on Linux, Windows and Mac OS the number of this list
27-
# must be multiplied by 3. 80 * 3 == 240 so we're in the green.
28-
TESTS_SPLIT = 80
29-
cycle = itertools.cycle(range(TESTS_SPLIT))
30-
groups = [[] for _ in range(TESTS_SPLIT)]
31-
for f in test_functions:
32-
index = next(cycle)
33-
groups[index].append(f)
349

35-
print(json.dumps([" ".join(g) for g in groups]))
10+
test_files = [str(f) for f in Path(tests_path).glob("test_*.py")]
11+
print(json.dumps(test_files))

0 commit comments

Comments
 (0)