[svn r37624] Slightly hackish way to put all tracing calls as low as possible. This
should kill unnecessary frames. Right now tracing is done only for py.test.Function objects, I don't know what to do with sth else, let's leave it alone. --HG-- branch : trunk
This commit is contained in:
parent
f65d6e9d35
commit
3630e7fcd3
|
@ -18,10 +18,13 @@ class RunExecutor(object):
|
||||||
self.reporter = reporter
|
self.reporter = reporter
|
||||||
self.config = config
|
self.config = config
|
||||||
assert self.config
|
assert self.config
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.item.run()
|
||||||
|
|
||||||
def execute(self):
|
def execute(self):
|
||||||
try:
|
try:
|
||||||
self.item.run()
|
self.run()
|
||||||
outcome = Outcome()
|
outcome = Outcome()
|
||||||
except py.test.Item.Skipped, e:
|
except py.test.Item.Skipped, e:
|
||||||
outcome = Outcome(skipped=str(e))
|
outcome = Outcome(skipped=str(e))
|
||||||
|
@ -49,8 +52,33 @@ class RunExecutor(object):
|
||||||
outcome.stderr = ""
|
outcome.stderr = ""
|
||||||
return outcome
|
return outcome
|
||||||
|
|
||||||
|
class ApigenExecutor(RunExecutor):
|
||||||
|
""" Same as RunExecutor, but takes tracer to trace calls as
|
||||||
|
an argument to execute
|
||||||
|
"""
|
||||||
|
def execute(self, tracer):
|
||||||
|
self.tracer = tracer
|
||||||
|
return super(ApigenExecutor, self).execute()
|
||||||
|
|
||||||
|
def wrap_underlaying(self, target):
|
||||||
|
def f(*args):
|
||||||
|
try:
|
||||||
|
self.tracer.start_tracing()
|
||||||
|
return target(*args)
|
||||||
|
finally:
|
||||||
|
self.tracer.end_tracing()
|
||||||
|
return f
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
""" We want to trace *only* function objects here. Unsure
|
||||||
|
what to do with custom collectors at all
|
||||||
|
"""
|
||||||
|
if hasattr(self.item, 'obj') and type(self.item.obj) is py.test.Function:
|
||||||
|
self.item.obj = self.wrap_underlaying(self.item.obj)
|
||||||
|
self.item.run()
|
||||||
|
|
||||||
class BoxExecutor(RunExecutor):
|
class BoxExecutor(RunExecutor):
|
||||||
""" Same as run executor, but boxes test instead
|
""" Same as RunExecutor, but boxes test instead
|
||||||
"""
|
"""
|
||||||
wraps = True
|
wraps = True
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
""" local-only operations
|
""" local-only operations
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from py.__.test.rsession.executor import BoxExecutor, RunExecutor
|
from py.__.test.rsession.executor import BoxExecutor, RunExecutor,\
|
||||||
|
ApigenExecutor
|
||||||
from py.__.test.rsession import report
|
from py.__.test.rsession import report
|
||||||
from py.__.test.rsession.outcome import ReprOutcome
|
from py.__.test.rsession.outcome import ReprOutcome
|
||||||
|
|
||||||
|
@ -37,13 +38,10 @@ def benchmark_runner(item, session, reporter):
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
def apigen_runner(item, session, reporter):
|
def apigen_runner(item, session, reporter):
|
||||||
r = RunExecutor(item, reporter=reporter, config=session.config)
|
|
||||||
startcapture(session)
|
startcapture(session)
|
||||||
#retval = plain_runner(item, session, reporter)
|
#retval = plain_runner(item, session, reporter)
|
||||||
r = RunExecutor(item, reporter=reporter, config=session.config)
|
r = ApigenExecutor(item, reporter=reporter, config=session.config)
|
||||||
session.tracer.start_tracing()
|
outcome = r.execute(session.tracer)
|
||||||
outcome = r.execute()
|
|
||||||
session.tracer.end_tracing()
|
|
||||||
outcome = ReprOutcome(outcome.make_repr(session.config.option.tbstyle))
|
outcome = ReprOutcome(outcome.make_repr(session.config.option.tbstyle))
|
||||||
outcome.stdout, outcome.stderr = finishcapture(session)
|
outcome.stdout, outcome.stderr = finishcapture(session)
|
||||||
return outcome
|
return outcome
|
||||||
|
|
Loading…
Reference in New Issue