Skip to content

Commit ae20ddc

Browse files
committed
test_tagged_unittests.py: split large test clis
1 parent 3d32174 commit ae20ddc

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

graalpython/com.oracle.graal.python.test/src/tests/test_tagged_unittests.py

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import subprocess
4343
import sys
4444
import test
45+
from itertools import zip_longest
4546

4647
if os.environ.get("ENABLE_CPYTHON_TAGGED_UNITTESTS") == "true" or __name__ == "__main__":
4748
TAGS_DIR = os.path.join(os.path.dirname(__file__), "unittest_tags")
@@ -52,6 +53,12 @@
5253
RUNNER = os.path.join(os.path.dirname(__file__), "run_cpython_test.py")
5354
LINE = "=" * 80
5455

56+
57+
def grouper(iterable, n):
58+
args = [iter(iterable)] * n
59+
return zip_longest(*args, fillvalue=None)
60+
61+
5562
def working_selectors(tagfile):
5663
if os.path.exists(tagfile):
5764
with open(tagfile) as f:
@@ -77,29 +84,30 @@ def collect_working_tests():
7784
def make_test_function(working_test):
7885
testmod = working_test[0].rpartition(".")[2]
7986

80-
def test_tagged():
81-
cmd = [sys.executable]
82-
if "--inspect" in sys.argv:
83-
cmd.append("--inspect")
84-
if "-debug-java" in sys.argv:
85-
cmd.append("-debug-java")
86-
cmd += [RUNNER]
87-
if "-vv" in sys.argv:
88-
cmd += ['-v']
89-
for testpattern in working_test[1]:
90-
cmd.extend(["-k", testpattern])
91-
print("Running test:", working_test[0])
92-
testfile = os.path.join(os.path.dirname(test.__file__), "%s.py" % testmod)
93-
if not os.path.isfile(testfile):
94-
testfile = os.path.join(os.path.dirname(test.__file__), "%s/__init__.py" % testmod)
95-
cmd.append(testfile)
96-
if os.environ.get("ENABLE_THREADED_GRAALPYTEST") == "true":
97-
run_serialize_out(cmd)
98-
else:
99-
rcode = run_with_timeout(cmd).returncode
100-
if rcode:
101-
raise CalledProcessError(rcode, cmd)
102-
print(working_test[0], "was finished.")
87+
def test_tagged(max_patterns=100):
88+
for working_test_group in grouper(working_test[1], max_patterns):
89+
cmd = [sys.executable]
90+
if "--inspect" in sys.argv:
91+
cmd.append("--inspect")
92+
if "-debug-java" in sys.argv:
93+
cmd.append("-debug-java")
94+
cmd += [RUNNER]
95+
if "-vv" in sys.argv:
96+
cmd += ['-v']
97+
for testpattern in working_test_group:
98+
cmd.extend(["-k", testpattern])
99+
print("Running test:", working_test[0])
100+
testfile = os.path.join(os.path.dirname(test.__file__), "%s.py" % testmod)
101+
if not os.path.isfile(testfile):
102+
testfile = os.path.join(os.path.dirname(test.__file__), "%s/__init__.py" % testmod)
103+
cmd.append(testfile)
104+
if os.environ.get("ENABLE_THREADED_GRAALPYTEST") == "true":
105+
run_serialize_out(cmd)
106+
else:
107+
rcode = run_with_timeout(cmd).returncode
108+
if rcode:
109+
raise CalledProcessError(rcode, cmd)
110+
print(working_test[0], "was finished.")
103111

104112
def run_serialize_out(cmd):
105113
result = run_with_timeout(cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

0 commit comments

Comments
 (0)