Commit 546e34b6 authored by Jeremy Hylton's avatar Jeremy Hylton

Enable tracing of multi-threaded applications.

Fix bug in computation of coverage percentage: Only count a line if it
was executed or if we print the >>>>>> marker.
parent 28b5bb33
...@@ -50,6 +50,7 @@ import marshal ...@@ -50,6 +50,7 @@ import marshal
import os import os
import re import re
import sys import sys
import threading
import token import token
import tokenize import tokenize
import types import types
...@@ -317,9 +318,9 @@ class CoverageResults: ...@@ -317,9 +318,9 @@ class CoverageResults:
# #pragma: NO COVER # #pragma: NO COVER
if lineno in lnotab and not PRAGMA_NOCOVER in lines[i]: if lineno in lnotab and not PRAGMA_NOCOVER in lines[i]:
outfile.write(">>>>>> ") outfile.write(">>>>>> ")
n_lines += 1
else: else:
outfile.write(" ") outfile.write(" ")
n_lines += 1
outfile.write(lines[i].expandtabs(8)) outfile.write(lines[i].expandtabs(8))
outfile.close() outfile.close()
...@@ -437,22 +438,26 @@ class Trace: ...@@ -437,22 +438,26 @@ class Trace:
dict = __main__.__dict__ dict = __main__.__dict__
if not self.donothing: if not self.donothing:
sys.settrace(self.globaltrace) sys.settrace(self.globaltrace)
threading.settrace(self.globaltrace)
try: try:
exec cmd in dict, dict exec cmd in dict, dict
finally: finally:
if not self.donothing: if not self.donothing:
sys.settrace(None) sys.settrace(None)
threading.settrace(None)
def runctx(self, cmd, globals=None, locals=None): def runctx(self, cmd, globals=None, locals=None):
if globals is None: globals = {} if globals is None: globals = {}
if locals is None: locals = {} if locals is None: locals = {}
if not self.donothing: if not self.donothing:
sys.settrace(self.globaltrace) sys.settrace(self.globaltrace)
threading.settrace(self.globaltrace)
try: try:
exec cmd in globals, locals exec cmd in globals, locals
finally: finally:
if not self.donothing: if not self.donothing:
sys.settrace(None) sys.settrace(None)
threading.settrace(None)
def runfunc(self, func, *args, **kw): def runfunc(self, func, *args, **kw):
result = None result = None
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment