Re: [pypy-svn] r20364 - in pypy/branch/somepbc-refactoring/pypy/translator/c: . test

mwh@codespeak.net wrote:
Author: mwh Date: Mon Nov 28 18:27:39 2005 New Revision: 20364
Modified: pypy/branch/somepbc-refactoring/pypy/translator/c/extfunc.py pypy/branch/somepbc-refactoring/pypy/translator/c/genc.py pypy/branch/somepbc-refactoring/pypy/translator/c/pyobj.py pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py pypy/branch/somepbc-refactoring/pypy/translator/c/wrapper.py Log: test_annotated passes again, though this is pretty much a 'hack-until-it- passes' approach.
I see,
Modified: pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py
--- pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py (original) +++ pypy/branch/somepbc-refactoring/pypy/translator/c/test/test_annotated.py Mon Nov 28 18:27:39 2005 @@ -1,7 +1,7 @@ import autopath import py, sys from pypy.translator.tool.cbuild import skip_missing_compiler -from pypy.translator.translator import Translator +from pypy.translator.translator import TranslationContext
from pypy.translator.test import snippet
@@ -12,7 +12,7 @@ class TestAnnotatedTestCase:
def getcompiled(self, func):
t = Translator(func, simplifying=True)
t = TranslationContext(simplifying=True) # builds starting-types from func_defs argstypelist = [] if func.func_defaults:
@@ -20,9 +20,15 @@ if isinstance(spec, tuple): spec = spec[0] # use the first type only for the tests argstypelist.append(spec)
a = t.annotate(argstypelist)
a = t.buildannotator()
a.build_types(func, argstypelist) a.simplify()
return skip_missing_compiler(t.ccompile)
from pypy.translator.c import genc
builder = genc.CExtModuleBuilder(t, func)
builder.generate_source()
skip_missing_compiler(builder.compile)
builder.import_module()
return builder.get_entry_point()
def test_set_attr(self): set_attr = self.getcompiled(snippet.set_attr)
I missed this subtle point, indeed before going on writing more code like this, we need to think where and how much of translator.Translator to keep working and where instead to switch using TranslationContext

Samuele Pedroni pedronis@strakt.com writes:
if isinstance(spec, tuple): spec = spec[0] # use the first type only for the tests argstypelist.append(spec)
a = t.annotate(argstypelist)
a = t.buildannotator()
a.build_types(func, argstypelist) a.simplify()
return skip_missing_compiler(t.ccompile)
from pypy.translator.c import genc
builder = genc.CExtModuleBuilder(t, func)
builder.generate_source()
skip_missing_compiler(builder.compile)
builder.import_module()
return builder.get_entry_point() def test_set_attr(self): set_attr = self.getcompiled(snippet.set_attr)
I missed this subtle point, indeed before going on writing more code like this, we need to think where and how much of translator.Translator to keep working and where instead to switch using TranslationContext
Definitely. I wrote that stuff largely to see how hard it would be and the answer is "not very, but it's a bit long winded". It's definitely too much to write in each test file. OTOH, it's hard to share this code between test files, because e.g. test_typed wants to do almost exactly the same but do rtyping in the middle. I'm a bit at a loss as to a clean design
callable = self.compile(f, "annotate") callable = self.compile(f, "annotate", "rtype") callable = self.compile(f, "annotate", "rtype", "backendopt")
?
Cheers, mwh
participants (2)
-
Michael Hudson
-
Samuele Pedroni