parent
c4ab38f5c9
commit
8cbb41521c
|
@ -24,7 +24,7 @@ def test_js_generate():
|
||||||
from py.__.test.rsession import webjs
|
from py.__.test.rsession import webjs
|
||||||
from py.__.test.rsession.web import FUNCTION_LIST, IMPORTED_PYPY
|
from py.__.test.rsession.web import FUNCTION_LIST, IMPORTED_PYPY
|
||||||
|
|
||||||
source = rpython2javascript(webjs, FUNCTION_LIST)
|
source = rpython2javascript(webjs, FUNCTION_LIST, use_pdb=False)
|
||||||
assert source
|
assert source
|
||||||
|
|
||||||
def test_parse_args():
|
def test_parse_args():
|
||||||
|
|
|
@ -24,11 +24,10 @@ FUNCTION_LIST = ["main", "show_skip", "show_traceback", "show_info", "hide_info"
|
||||||
"show_host", "hide_host", "hide_messagebox", "opt_scroll"]
|
"show_host", "hide_host", "hide_messagebox", "opt_scroll"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal,\
|
from pypy.rpython.ootypesystem.bltregistry import MethodDesc, BasicExternal
|
||||||
described
|
|
||||||
from pypy.translator.js.main import rpython2javascript
|
from pypy.translator.js.main import rpython2javascript
|
||||||
from pypy.translator.js import commproxy
|
from pypy.translator.js import commproxy
|
||||||
from pypy.rpython.extfunc import _callable
|
from pypy.translator.js.lib.support import callback
|
||||||
|
|
||||||
commproxy.USE_MOCHIKIT = False
|
commproxy.USE_MOCHIKIT = False
|
||||||
IMPORTED_PYPY = True
|
IMPORTED_PYPY = True
|
||||||
|
@ -36,14 +35,11 @@ except (ImportError, NameError):
|
||||||
class BasicExternal(object):
|
class BasicExternal(object):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def described(*args, **kwargs):
|
def callback(*args, **kwargs):
|
||||||
def decorator(func):
|
def decorator(func):
|
||||||
return func
|
return func
|
||||||
return decorator
|
return decorator
|
||||||
|
|
||||||
def _callable(*args, **kwargs):
|
|
||||||
pass
|
|
||||||
|
|
||||||
IMPORTED_PYPY = False
|
IMPORTED_PYPY = False
|
||||||
|
|
||||||
def add_item(event):
|
def add_item(event):
|
||||||
|
@ -153,22 +149,19 @@ class ExportedMethods(BasicExternal):
|
||||||
for host in self.hosts:
|
for host in self.hosts:
|
||||||
to_send[host.hostid] = host.hostname
|
to_send[host.hostid] = host.hostname
|
||||||
return to_send
|
return to_send
|
||||||
show_hosts = described(retval={str:str}, args=[('callback',
|
show_hosts = callback(retval={str:str})(show_hosts)
|
||||||
_callable([{str:str}]))])(show_hosts)
|
|
||||||
|
|
||||||
def show_skip(self, item_name="aa"):
|
def show_skip(self, item_name="aa"):
|
||||||
return {'item_name': item_name,
|
return {'item_name': item_name,
|
||||||
'reason': self.skip_reasons[item_name]}
|
'reason': self.skip_reasons[item_name]}
|
||||||
show_skip = described(retval={str:str}, args=[('item_name',str),('callback',
|
show_skip = callback(retval={str:str})(show_skip)
|
||||||
_callable([{str:str}]))])(show_skip)
|
|
||||||
|
|
||||||
def show_fail(self, item_name="aa"):
|
def show_fail(self, item_name="aa"):
|
||||||
return {'item_name':item_name,
|
return {'item_name':item_name,
|
||||||
'traceback':str(self.fail_reasons[item_name]),
|
'traceback':str(self.fail_reasons[item_name]),
|
||||||
'stdout':self.stdout[item_name],
|
'stdout':self.stdout[item_name],
|
||||||
'stderr':self.stderr[item_name]}
|
'stderr':self.stderr[item_name]}
|
||||||
show_fail = described(retval={str:str}, args=[('item_name',str),('callback',
|
show_fail = callback(retval={str:str})(show_fail)
|
||||||
_callable([{str:str}]))])(show_fail)
|
|
||||||
|
|
||||||
_sessids = None
|
_sessids = None
|
||||||
_sesslock = py.std.thread.allocate_lock()
|
_sesslock = py.std.thread.allocate_lock()
|
||||||
|
@ -186,8 +179,7 @@ class ExportedMethods(BasicExternal):
|
||||||
finally:
|
finally:
|
||||||
self._sesslock.release()
|
self._sesslock.release()
|
||||||
return sessid
|
return sessid
|
||||||
show_sessid = described(retval=str, args=[('callback',
|
show_sessid = callback(retval=str)(show_sessid)
|
||||||
_callable([str]))])(show_sessid)
|
|
||||||
|
|
||||||
def failed(self, **kwargs):
|
def failed(self, **kwargs):
|
||||||
if not 'sessid' in kwargs:
|
if not 'sessid' in kwargs:
|
||||||
|
@ -201,14 +193,13 @@ class ExportedMethods(BasicExternal):
|
||||||
del self._sessids[to_del]
|
del self._sessids[to_del]
|
||||||
self.pending_events._del(kwargs['sessid'])
|
self.pending_events._del(kwargs['sessid'])
|
||||||
|
|
||||||
def show_all_statuses(self, sessid=-1):
|
def show_all_statuses(self, sessid='xx'):
|
||||||
retlist = [self.show_status_change(sessid)]
|
retlist = [self.show_status_change(sessid)]
|
||||||
while not self.pending_events.empty_queue(sessid):
|
while not self.pending_events.empty_queue(sessid):
|
||||||
retlist.append(self.show_status_change(sessid))
|
retlist.append(self.show_status_change(sessid))
|
||||||
retval = retlist
|
retval = retlist
|
||||||
return retval
|
return retval
|
||||||
show_all_statuses = described(retval=[{str:str}],args=
|
show_all_statuses = callback(retval=[{str:str}])(show_all_statuses)
|
||||||
[('sessid',str), ('callback',_callable([[{str:str}]]))])(show_all_statuses)
|
|
||||||
|
|
||||||
def show_status_change(self, sessid):
|
def show_status_change(self, sessid):
|
||||||
event = self.pending_events.get(sessid)
|
event = self.pending_events.get(sessid)
|
||||||
|
@ -408,7 +399,8 @@ class TestHandler(BaseHTTPRequestHandler):
|
||||||
def run_jssource(self):
|
def run_jssource(self):
|
||||||
js_name = py.path.local(__file__).dirpath("webdata").join("source.js")
|
js_name = py.path.local(__file__).dirpath("webdata").join("source.js")
|
||||||
web_name = py.path.local(__file__).dirpath().join("webjs.py")
|
web_name = py.path.local(__file__).dirpath().join("webjs.py")
|
||||||
if IMPORTED_PYPY and web_name.mtime() > js_name.mtime():
|
if IMPORTED_PYPY and web_name.mtime() > js_name.mtime() or \
|
||||||
|
(not js_name.check()) or 1:
|
||||||
from py.__.test.rsession import webjs
|
from py.__.test.rsession import webjs
|
||||||
|
|
||||||
javascript_source = rpython2javascript(webjs,
|
javascript_source = rpython2javascript(webjs,
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue