[pypy-svn] r4963 - pypy/trunk/src/pypy/translator/test

hpk at codespeak.net hpk at codespeak.net
Sat Jun 5 14:58:05 CEST 2004


Author: hpk
Date: Sat Jun  5 14:58:05 2004
New Revision: 4963

Modified:
   pypy/trunk/src/pypy/translator/test/run_snippet.py
Log:
- default run mode (no arguments) is to run all snippets
  and only report

- with cmdline args it will only run functions starting 
  with the given prefixes 



Modified: pypy/trunk/src/pypy/translator/test/run_snippet.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/run_snippet.py	(original)
+++ pypy/trunk/src/pypy/translator/test/run_snippet.py	Sat Jun  5 14:58:05 2004
@@ -40,10 +40,16 @@
         compiled_function = self.translator.compile()
         return compiled_function
     
-def collect_functions(module):
+def collect_functions(module, specnamelist):
     l = []
-    for name, value in vars(module).items():
-        if name[0] != '_' and hasattr(value, 'func_code'):
+    for funcname, value in vars(module).items():
+        if not hasattr(value, 'func_code'):
+            continue
+        for specname in specnamelist:
+            if funcname.startswith(specname):
+                l.append(value)
+                break
+        if not specnamelist:
             l.append(value) 
     return l
    
@@ -72,8 +78,8 @@
     return format_str %(funccall, flow, ann, comp)
      
 if __name__=='__main__':
-    funcs = collect_functions(snippet)
-    funcs.insert(0, snippet._attrs) 
+    specnamelist = sys.argv[1:]
+    funcs = collect_functions(snippet, specnamelist) 
     results = []
     print format_str %("functioncall", "flowed", "annotated", "compiled")
     for func in funcs:
@@ -81,6 +87,9 @@
             result = Result(func, argtypeslist) 
             results.append(result) 
             print repr_result(result) 
+            if specnamelist and getattr(result, 'excinfo', None): 
+                traceback.print_exception(*result.excinfo) 
+                raise SystemExit, 1
     
     for res in results:
         print repr_result(res) 



More information about the Pypy-commit mailing list