[pypy-svn] r13516 - in pypy/dist/pypy/rpython: . test
hpk at codespeak.net
hpk at codespeak.net
Fri Jun 17 07:46:50 CEST 2005
Author: hpk
Date: Fri Jun 17 07:46:49 2005
New Revision: 13516
Modified:
pypy/dist/pypy/rpython/interp.py
pypy/dist/pypy/rpython/test/test_interp.py
Log:
- use new logging API, re-enable logging API from tests
Modified: pypy/dist/pypy/rpython/interp.py
==============================================================================
--- pypy/dist/pypy/rpython/interp.py (original)
+++ pypy/dist/pypy/rpython/interp.py Fri Jun 17 07:46:49 2005
@@ -5,12 +5,13 @@
from pypy.objspace.flow.model import Constant, last_exception
import py
+log = py.log.Producer('llinterp')
+
class RPythonError(Exception):
pass
class LLInterpreter(object):
""" low level interpreter working with concrete values. """
-# log = py.log.Producer('llinterp')
def __init__(self, flowgraphs, typer):
self.flowgraphs = flowgraphs
@@ -30,7 +31,6 @@
def setvar(self, var, val):
# XXX assert that val "matches" lowlevel type
-
self.bindings[var] = val
def getval(self, varorconst):
@@ -59,6 +59,7 @@
return self.eval_graph(graph,args)
def eval_graph(self, graph, args=()):
+ log.graph("evaluating", graph.name)
nextblock = graph.startblock
excblock = graph.exceptblock
while 1:
@@ -99,7 +100,7 @@
raise RPythonError(etype, evalue)
resultvar, = block.getvariables()
result = self.getval(resultvar)
-# self.log.operation("returning", result)
+ log.operation("returning", result)
return None, result
elif block.exitswitch is None:
# single-exit block
@@ -124,7 +125,7 @@
return link.target, [self.getval(x) for x in link.args]
def eval_operation(self, operation):
-# self.log.operation("considering", operation)
+ log.operation("considering", operation)
ophandler = self.getoperationhandler(operation.opname)
vals = [self.getval(x) for x in operation.args]
# if these special cases pile up, do something better here
@@ -178,7 +179,6 @@
def op_getarraysubstruct(self, array, index):
assert isinstance(array, _ptr)
-
return array[index]
# the diff between op_getarrayitem and op_getarraysubstruct
# is the same as between op_getfield and op_getsubstruct
@@ -217,3 +217,7 @@
return func(x)
""" % locals()).compile()
+# by default we route all logging messages to nothingness
+# e.g. tests can then switch on logging to get more help
+# for failing tests
+py.log.setconsumer('llinterp', None)
Modified: pypy/dist/pypy/rpython/test/test_interp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_interp.py (original)
+++ pypy/dist/pypy/rpython/test/test_interp.py Fri Jun 17 07:46:49 2005
@@ -1,12 +1,20 @@
import py
-py.magic.autopath()
from pypy.rpython.lltype import typeOf
from pypy.rpython.rtyper import RPythonTyper
from pypy.rpython.interp import LLInterpreter, RPythonError
from pypy.translator.translator import Translator
from pypy.rpython.lltype import pyobjectptr
+# switch on logging of interp to show more info on failing tests
+
+def setup_module(mod):
+ mod.logstate = py.log._getstate()
+ py.log.setconsumer("llinterp", py.log.STDOUT)
+
+def teardown_module(mod):
+ py.log._setstate(mod.logstate)
+
def find_exception(exc):
assert isinstance(exc, RPythonError)
import exceptions
More information about the Pypy-commit
mailing list