@@ -194,6 +194,7 @@ def run_old_pypy_test_on(filename):
194194luajs_runnable = os .path .isfile ( lua2js ) and '--lua2js' in sys .argv
195195
196196go_runnable = runnable ( 'go version' )
197+ gopherjs_runnable = runnable ( 'gopherjs' )
197198
198199assert rhino_runnable or node_runnable
199200
@@ -474,7 +475,7 @@ def run_python3_test_on(filename):
474475
475476
476477
477- def translate_js (filename , javascript = False , dart = False , coffee = False , lua = False , luajs = False , go = False , multioutput = False , requirejs = True ):
478+ def translate_js (filename , javascript = False , dart = False , coffee = False , lua = False , luajs = False , go = False , gopherjs = False , multioutput = False , requirejs = True ):
478479 global tmpname
479480 tmpname = os .path .join (
480481 tempfile .gettempdir (),
@@ -506,7 +507,7 @@ def translate_js(filename, javascript=False, dart=False, coffee=False, lua=False
506507 ]
507508 content = '\n ' .join ( source )
508509
509- elif go :
510+ elif go or gopherjs :
510511 content = patch_python (filename , backend = 'GO' )
511512
512513 else :
@@ -535,6 +536,8 @@ def translate_js(filename, javascript=False, dart=False, coffee=False, lua=False
535536 cmd .append ( '--luajs' )
536537 elif go :
537538 cmd .append ( '--go' )
539+ elif gopherjs :
540+ cmd .append ( '--gopherjs' )
538541
539542 if not requirejs :
540543 cmd .append ( '--no-wrapper' )
@@ -799,6 +802,15 @@ def run_go(content):
799802 return run_command ( '/tmp/regtest-go' )
800803
801804
805+ def run_pythonjs_gopherjs_test (dummy_filename ):
806+ """PythonJS (Gopherjs)"""
807+ return run_if_no_error (run_gopherjs_node )
808+
809+ def run_gopherjs_node (content ):
810+ """Run Gopherjs using Node"""
811+ write ("%s.js" % tmpname , content )
812+ return run_command ("node %s.js" % tmpname )
813+
802814def run_html_test ( filename , sum_errors ):
803815 lines = open (filename , 'rb' ).read ().decode ('utf-8' ).splitlines ()
804816 filename = os .path .split (filename )[- 1 ]
@@ -967,6 +979,9 @@ def display(function):
967979 js = translate_js (filename , go = True )
968980 display (run_pythonjs_go_test )
969981
982+ if gopherjs_runnable :
983+ js = translate_js (filename , gopherjs = True )
984+ display (run_pythonjs_gopherjs_test )
970985
971986 print ()
972987 return sum_errors
0 commit comments