##// END OF EJS Templates
Produce coverage xml reports from subprocess test runners.
Thomas Kluyver -
Show More
@@ -267,6 +267,8 b' class IPTester(object):'
267 267 call_args = None
268 268 #: list, process ids of subprocesses we start (for cleanup)
269 269 pids = None
270 #: str, coverage xml output file
271 coverage_xml = None
270 272
271 273 def __init__(self, runner='iptest', params=None):
272 274 """Create new test runner."""
@@ -285,9 +287,14 b' class IPTester(object):'
285 287 # Assemble call
286 288 self.call_args = self.runner+self.params
287 289
290 sect = [p for p in self.params if p.startswith('IPython')][0]
288 291 if '--with-xunit' in self.call_args:
289 sect = [p for p in self.params if p.startswith('IPython')][0]
290 292 self.call_args.append('--xunit-file=%s' % path.abspath(sect+'.xunit.xml'))
293
294 if '--with-coverage' in self.call_args:
295 self.coverage_xml = path.abspath(sect+".coverage.xml")
296 self.call_args.remove('--with-coverage')
297 self.call_args = ["python-coverage", "run", "--source="+sect] + self.call_args[1:]
291 298
292 299 # Store pids of anything we start to clean up on deletion, if possible
293 300 # (on posix only, since win32 has no os.kill)
@@ -319,11 +326,15 b' class IPTester(object):'
319 326 def run(self):
320 327 """Run the stored commands"""
321 328 try:
322 return self._run_cmd()
329 retcode = self._run_cmd()
323 330 except:
324 331 import traceback
325 332 traceback.print_exc()
326 333 return 1 # signal failure
334
335 if self.coverage_xml:
336 subprocess.check_call(["python-coverage", "xml", "-o", self.coverage_xml])
337 return retcode
327 338
328 339 def __del__(self):
329 340 """Cleanup on exit by killing any leftover processes."""
General Comments 0
You need to be logged in to leave comments. Login now