42
42
import subprocess
43
43
import sys
44
44
import test
45
+ from itertools import zip_longest
45
46
46
47
if os .environ .get ("ENABLE_CPYTHON_TAGGED_UNITTESTS" ) == "true" or __name__ == "__main__" :
47
48
TAGS_DIR = os .path .join (os .path .dirname (__file__ ), "unittest_tags" )
52
53
RUNNER = os .path .join (os .path .dirname (__file__ ), "run_cpython_test.py" )
53
54
LINE = "=" * 80
54
55
56
+
57
+ def grouper (iterable , n ):
58
+ args = [iter (iterable )] * n
59
+ return zip_longest (* args , fillvalue = None )
60
+
61
+
55
62
def working_selectors (tagfile ):
56
63
if os .path .exists (tagfile ):
57
64
with open (tagfile ) as f :
@@ -77,29 +84,30 @@ def collect_working_tests():
77
84
def make_test_function (working_test ):
78
85
testmod = working_test [0 ].rpartition ("." )[2 ]
79
86
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." )
103
111
104
112
def run_serialize_out (cmd ):
105
113
result = run_with_timeout (cmd , stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
0 commit comments