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