[pypy-svn] r23027 - in pypy/dist/pypy: . jit/test rpython/test
arigo at codespeak.net
arigo at codespeak.net
Sat Feb 4 17:48:29 CET 2006
Author: arigo
Date: Sat Feb 4 17:48:26 2006
New Revision: 23027
Modified:
pypy/dist/pypy/conftest.py
pypy/dist/pypy/jit/test/test_hint_annotation.py
pypy/dist/pypy/rpython/test/test_llinterp.py
Log:
Add the --view option to py.test (pypy/test_all), which is supposed to trigger
the Pygame viewer to see the flow graphs during the tests. The tests need to
check "pypy.conftest.option.view" explicitly for this to work; so far I've
only done it in jit/test/test_hint_annotation and rpython/test_llinterp.
Modified: pypy/dist/pypy/conftest.py
==============================================================================
--- pypy/dist/pypy/conftest.py (original)
+++ pypy/dist/pypy/conftest.py Sat Feb 4 17:48:26 2006
@@ -38,7 +38,9 @@
help="(mixed) modules to use."),
Option('--compiler', action="store", type="string", dest="compiler",
metavar="[ast|cpython]", default='ast',
- help="""select compiling approach. see pypy/doc/README.compiling""")
+ help="""select compiling approach. see pypy/doc/README.compiling"""),
+ Option('--view', action="store_true", dest="view", default=False,
+ help="view translation tests' flow graphs with Pygame"),
)
_SPACECACHE={}
@@ -160,7 +162,7 @@
raise self.Failed(excinfo=appsupport.AppExceptionInfo(space, e))
raise
-_pygame_warned = False
+_pygame_imported = False
class IntTestFunction(PyPyTestFunction):
def execute(self, target, *args):
@@ -175,11 +177,11 @@
check_keyboard_interrupt(e)
raise
if 'pygame' in sys.modules:
- global _pygame_warned
- if not _pygame_warned:
- _pygame_warned = True
- py.test.skip("DO NOT FORGET to remove the Pygame invocation "
- "before checking in :-)")
+ global _pygame_imported
+ if not _pygame_imported:
+ _pygame_imported = True
+ assert option.view, ("should not invoke Pygame "
+ "if conftest.option.view is False")
class AppTestFunction(PyPyTestFunction):
def execute(self, target, *args):
Modified: pypy/dist/pypy/jit/test/test_hint_annotation.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_hint_annotation.py (original)
+++ pypy/dist/pypy/jit/test/test_hint_annotation.py Sat Feb 4 17:48:26 2006
@@ -7,6 +7,7 @@
from pypy.rpython.objectmodel import hint
from pypy.annotation import model as annmodel
from pypy.annotation.policy import AnnotatorPolicy
+from pypy import conftest
P_OOPSPEC = AnnotatorPolicy()
P_OOPSPEC.oopspec = True
@@ -26,7 +27,8 @@
{OriginFlags(): True})
for v in graph1.getargs()])
t = hannotator.translator
- #t.view()
+ if conftest.option.view:
+ t.view()
if annotator:
return hs, hannotator
else:
Modified: pypy/dist/pypy/rpython/test/test_llinterp.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_llinterp.py (original)
+++ pypy/dist/pypy/rpython/test/test_llinterp.py Sat Feb 4 17:48:26 2006
@@ -9,6 +9,7 @@
from pypy.rpython import rstr
from pypy.annotation.model import lltype_to_annotation
from pypy.rpython.rarithmetic import r_uint, ovfcheck
+from pypy import conftest
# switch on logging of interp to show more info on failing tests
@@ -43,11 +44,13 @@
#print "%.2f secs" %(elapsed,)
return res
-def gengraph(func, argtypes=[], viewbefore=False, policy=None,
+def gengraph(func, argtypes=[], viewbefore='auto', policy=None,
type_system="lltype"):
t = TranslationContext()
a = t.buildannotator(policy=policy)
timelog("annotating", a.build_types, func, argtypes)
+ if viewbefore == 'auto':
+ viewbefore = conftest.option.view
if viewbefore:
a.simplify()
t.view()
@@ -62,7 +65,7 @@
_lastinterpreted = []
_tcache = {}
-def get_interpreter(func, values, view=False, viewbefore=False, policy=None,
+def get_interpreter(func, values, view='auto', viewbefore='auto', policy=None,
someobjects=False, type_system="lltype"):
key = (func,) + tuple([typeOf(x) for x in values])+ (someobjects,)
try:
@@ -85,17 +88,19 @@
_lastinterpreted.append(key)
if len(_lastinterpreted) >= 4:
del _tcache[_lastinterpreted.pop(0)]
+ if view == 'auto':
+ view = conftest.option.view
if view:
t.view()
return interp, graph
-def interpret(func, values, view=False, viewbefore=False, policy=None,
+def interpret(func, values, view='auto', viewbefore='auto', policy=None,
someobjects=False, type_system="lltype"):
interp, graph = get_interpreter(func, values, view, viewbefore, policy,
someobjects, type_system=type_system)
return interp.eval_graph(graph, values)
-def interpret_raises(exc, func, values, view=False, viewbefore=False,
+def interpret_raises(exc, func, values, view='auto', viewbefore='auto',
policy=None, someobjects=False, type_system="lltype"):
interp, graph = get_interpreter(func, values, view, viewbefore, policy,
someobjects, type_system=type_system)
@@ -148,7 +153,7 @@
interpret_raises(ValueError, call_raise_twice, [43, 7])
def test_call_raise_intercept():
- res = interpret(call_raise_intercept, [41], view=False)
+ res = interpret(call_raise_intercept, [41])
assert res == 41
res = interpret(call_raise_intercept, [42])
assert res == 42
More information about the Pypy-commit
mailing list