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

fijal at codespeak.net fijal at codespeak.net
Thu Jun 28 10:49:33 CEST 2007


Author: fijal
Date: Thu Jun 28 10:49:33 2007
New Revision: 44584

Modified:
   pypy/dist/pypy/translator/driver.py
   pypy/dist/pypy/translator/test/test_driver.py
Log:
Make entry_point default target if target function is not specified


Modified: pypy/dist/pypy/translator/driver.py
==============================================================================
--- pypy/dist/pypy/translator/driver.py	(original)
+++ pypy/dist/pypy/translator/driver.py	Thu Jun 28 10:49:33 2007
@@ -753,9 +753,16 @@
         if backend == 'cli':
             from pypy.translator.cli.support import patch
             driver.old_cli_defs = patch()
-        
-        target = targetspec_dic['target']
-        spec = target(driver, args)
+
+        if 'target' in targetspec_dic:
+            target = targetspec_dic['target']
+            spec = target(driver, args)
+        else:
+            try:
+                entry_point = targetspec_dic['entry_point']
+            except KeyError:
+                raise ValueError("Target spec doesn't seem to have target nor entry_point")
+            spec = entry_point, None
 
         try:
             entry_point, inputtypes, policy = spec

Modified: pypy/dist/pypy/translator/test/test_driver.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_driver.py	(original)
+++ pypy/dist/pypy/translator/test/test_driver.py	Thu Jun 28 10:49:33 2007
@@ -63,3 +63,15 @@
                 'run_c', 'prehannotatebackendopt', 'hintannotate', 'timeshift']
 
     assert cmpl(td.exposed, expected)
+
+def test_from_targetspecdic():
+    py.test.raises(ValueError, TranslationDriver.from_targetspec, {})
+    def f(argv):
+        return 0
+    driver = TranslationDriver.from_targetspec({'entry_point':f})
+    assert driver.entry_point is f
+    def target(driver, args):
+        return f, None
+    driver = TranslationDriver.from_targetspec({'target':target})
+    assert driver.entry_point is f
+



More information about the Pypy-commit mailing list