@@ -100,6 +100,7 @@ def fun():
100
100
101
101
executable = sys .executable .split (" " ) # HACK: our sys.executable on Java is a cmdline
102
102
re_success = re .compile ("(test\S+) \(([^\s]+)\) \.\.\. ok$" , re .MULTILINE )
103
+ re_failure = re .compile ("(test\S+) \(([^\s]+)\) \.\.\. (?:ERROR|FAIL)$" , re .MULTILINE )
103
104
kwargs = {"stdout" : subprocess .PIPE , "stderr" : subprocess .PIPE , "text" : True , "check" : False }
104
105
105
106
glob_pattern = os .path .join (os .path .dirname (test .__file__ ), "test_*.py" )
@@ -169,6 +170,7 @@ def fun():
169
170
# we failed the first run, create a tag file with the passing
170
171
# tests (if any)
171
172
passing_tests = []
173
+ failed_tests = []
172
174
173
175
try :
174
176
imported_test_module = __import__ (testmod )
@@ -191,13 +193,24 @@ def get_pass_name(funcname, classname):
191
193
192
194
# n.b.: we add a '*' in the front, so that unittests doesn't add
193
195
# its own asterisks, because now this is already a pattern
196
+
197
+ for funcname ,classname in re_failure .findall (p .stdout ):
198
+ failed_tests .append ("*" + get_pass_name (funcname , classname ))
199
+ for funcname ,classname in re_failure .findall (p .stderr ):
200
+ failed_tests .append ("*" + get_pass_name (funcname , classname ))
201
+
194
202
for funcname ,classname in re_success .findall (p .stdout ):
195
203
passing_tests .append ("*" + get_pass_name (funcname , classname ))
196
204
for funcname ,classname in re_success .findall (p .stderr ):
197
205
passing_tests .append ("*" + get_pass_name (funcname , classname ))
198
206
207
+ # n.b.: unittests uses the __qualname__ of the function as
208
+ # pattern, which we're trying to do as well. however, sometimes
209
+ # the same function is shared in multiple test classes, and
210
+ # fails in some. so we always subtract the failed patterns from
211
+ # the passed patterns
199
212
with open (tagfile , "w" ) as f :
200
- for passing_test in passing_tests :
213
+ for passing_test in set ( passing_tests ) - set ( failed_tests ) :
201
214
f .write (passing_test )
202
215
f .write ("\n " )
203
216
if not passing_tests :
0 commit comments