[pypy-svn] r39168 - pypy/dist/pypy/lang/js/test/ecma

fijal at codespeak.net fijal at codespeak.net
Sun Feb 18 19:09:42 CET 2007


Author: fijal
Date: Sun Feb 18 19:09:38 2007
New Revision: 39168

Modified:
   pypy/dist/pypy/lang/js/test/ecma/conftest.py
Log:
At least --collectonly works. Breaks tests a bit (error reporting)
but it's still better. This is intermediate checkin


Modified: pypy/dist/pypy/lang/js/test/ecma/conftest.py
==============================================================================
--- pypy/dist/pypy/lang/js/test/ecma/conftest.py	(original)
+++ pypy/dist/pypy/lang/js/test/ecma/conftest.py	Sun Feb 18 19:09:38 2007
@@ -22,33 +22,43 @@
 
 
 class JSTestFile(py.test.collect.Collector):
+    def init_interp(cls):
+        cls.interp = Interpreter()
+        ctx = cls.interp.global_context
+        shellpath = rootdir/'shell.js'
+        t = load_source(shellpath.read())
+        t.execute(ctx)
+    init_interp = classmethod(init_interp)
+    
     def __init__(self, filepath, parent=None):
         super(JSTestFile, self).__init__(filepath, parent)
         self.name = filepath.purebasename + " JSFILE"
         self.filepath = filepath
     
     def run(self):
+        if not option.ecma:
+            py.test.skip("ECMA tests disabled, run with --ecma")
         #actually run the file :)
         t = load_source(self.filepath.read())
         try:
-            t.execute(interp.global_context)
+            t.execute(self.interp.global_context)
         except:
             py.test.fail("Could not load js file")
-        testcases = interp.global_context.resolve_identifier('testcases')
+        testcases = self.interp.global_context.resolve_identifier('testcases')
         values = testcases.GetValue().array
-        testcases.PutValue(W_Array(), interp.global_context)
+        testcases.PutValue(W_Array(), self.interp.global_context)
         return values
 
     def join(self, name):
         return JSTestItem(name, parent = self)
 
-class JSTestItem(py.__.test.item.Item):        
+class JSTestItem(py.test.collect.Item):        
     def __init__(self, name, parent=None):
         #super(JSTestItem, self).__init__(filepath, parent)
         self.name = name
          
     def run():
-        ctx = interp.global_context
+        ctx = JSTestFile.interp.global_context
         r3 = ctx.resolve_identifier('run_test').GetValue()
         result = r3.Call(ctx=ctx, args=[name,]).ToNumber()
         if result == 0:
@@ -56,11 +66,4 @@
         elif result == -1:
             py.test.skip()
 
-if option.ecma:
-    global interp
-    interp = Interpreter()
-    ctx = interp.global_context
-    shellpath = rootdir/'shell.js'
-    t = load_source(shellpath.read())
-    t.execute(ctx)
-    Directory = JSDirectory
\ No newline at end of file
+Directory = JSDirectory



More information about the Pypy-commit mailing list