[pypy-svn] r28811 - in pypy/dist/pypy/translator/cli: . test

antocuni at codespeak.net antocuni at codespeak.net
Thu Jun 15 14:48:29 CEST 2006


Author: antocuni
Date: Thu Jun 15 14:48:23 2006
New Revision: 28811

Modified:
   pypy/dist/pypy/translator/cli/gencli.py
   pypy/dist/pypy/translator/cli/test/runtest.py
Log:
Moved build_exe() from runtest.py to gencli.py. Needed for integrating
gencli with traslator/driver.py.



Modified: pypy/dist/pypy/translator/cli/gencli.py
==============================================================================
--- pypy/dist/pypy/translator/cli/gencli.py	(original)
+++ pypy/dist/pypy/translator/cli/gencli.py	Thu Jun 15 14:48:23 2006
@@ -1,5 +1,6 @@
 import sys
-from types import MethodType
+import subprocess
+import shutil
 
 from pypy.translator.cli import conftest
 from pypy.translator.cli.ilgenerator import IlasmGenerator
@@ -9,6 +10,9 @@
 from pypy.translator.cli.database import LowLevelDatabase
 from pypy.translator.cli.cts import CTS
 from pypy.translator.cli.opcodes import opcodes
+from pypy.translator.cli.sdk import SDK
+from pypy.translator.cli.rte import get_pypy_dll
+
 
 class Tee(object):
     def __init__(self, *args):
@@ -74,7 +78,6 @@
             node = self.db._pending_nodes.pop()
             node.render(self.ilasm)
             self.db._rendered_nodes.add(node)
-            
 
     def fix_names(self):
         # it could happen that two distinct graph have the same name;
@@ -84,3 +87,18 @@
             while graph.name in names:
                 graph.name += '_'
             names.add(graph.name)
+
+    def build_exe(self):        
+        tmpfile = self.generate_source()
+        if getoption('source'):
+            return None
+
+        pypy_dll = get_pypy_dll() # get or recompile pypy.dll
+        shutil.copy(pypy_dll, self.tmpdir.strpath)
+
+        ilasm = SDK.ilasm()
+        proc = subprocess.Popen([ilasm, tmpfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        stdout, stderr = proc.communicate()
+        retval = proc.wait()
+        assert retval == 0, 'ilasm failed to assemble %s (%s):\n%s' % (self.graph.name, tmpfile, stdout)
+        return tmpfile.replace('.il', '.exe')

Modified: pypy/dist/pypy/translator/cli/test/runtest.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/runtest.py	(original)
+++ pypy/dist/pypy/translator/cli/test/runtest.py	Thu Jun 15 14:48:23 2006
@@ -1,6 +1,5 @@
 import os
 import subprocess
-import shutil
 
 import py
 from pypy.tool.udir import udir
@@ -17,7 +16,6 @@
 from pypy.translator.cli.cts import CTS
 from pypy.translator.cli.database import LowLevelDatabase
 from pypy.translator.cli.sdk import SDK
-from pypy.translator.cli.rte import get_pypy_dll
 
 FLOAT_PRECISION = 8
 
@@ -115,7 +113,7 @@
     def __init__(self, func, annotation=[], graph=None):
         self._func = func
         self._gen = self._build_gen(func, annotation, graph)
-        self._exe = self._build_exe()
+        self._exe = self._gen.build_exe()
 
     def _build_gen(self, func, annotation, graph=None):
         try: 
@@ -156,20 +154,6 @@
 
         return GenCli(self.tmpdir, t, TestEntryPoint(self.graph), pending_graphs=[raiseKeyError_graph])
 
-    def _build_exe(self):        
-        tmpfile = self._gen.generate_source()
-        if getoption('source'):
-            return None
-
-        pypy_dll = get_pypy_dll() # get or recompile pypy.dll
-        shutil.copy(pypy_dll, self.tmpdir.strpath)
-
-        ilasm = SDK.ilasm()
-        proc = subprocess.Popen([ilasm, tmpfile], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
-        stdout, stderr = proc.communicate()
-        retval = proc.wait()
-        assert retval == 0, 'ilasm failed to assemble %s (%s):\n%s' % (self.graph.name, tmpfile, stdout)
-        return tmpfile.replace('.il', '.exe')
 
     def __call__(self, *args):
         if self._exe is None:



More information about the Pypy-commit mailing list