@@ -63,7 +63,7 @@ def test_and_get_html( inpt, name, actions=set({}) ) :
6363
6464 return html
6565
66- def test_plumed ( executible , filename , header = [], printjson = False , jsondir = "./" ) :
66+ def test_plumed ( executible , filename , header = [], printjson = False , jsondir = "./" , cmdTimeout : "None|float" = None ) :
6767 """
6868 Test if plumed can parse this input file
6969
@@ -75,6 +75,7 @@ def test_plumed( executible, filename, header=[], printjson=False, jsondir="./"
7575 header -- A string to put at the top of the error page that is output
7676 printjson -- Set true if you want to used plumed to print the files containing the expansions of shortcuts and the value dictionary
7777 jsondir -- The directory in which to output the files containing the expansions of the shortcuts and the value dictionaries
78+ cmdTimeout -- Set the timeout for the plumed test
7879 """
7980 # Get the information for running the code
8081 run_folder = str (pathlib .PurePosixPath (filename ).parent )
@@ -107,7 +108,12 @@ def test_plumed( executible, filename, header=[], printjson=False, jsondir="./"
107108 with cd (run_folder ):
108109 for bkpf in glob .glob ("bck.*" ) :
109110 if os .path .isfile (bkpf ) : os .remove (bkpf )
110- plumed_out = subprocess .run (cmd , text = True , stdout = stdout , stderr = stderr )
111+ try :
112+ plumed_out = subprocess .run (cmd , text = True , stdout = stdout , stderr = stderr , timeout = cmdTimeout )
113+ returnCode = plumed_out .returncode
114+ except subprocess .TimeoutExpired :
115+ returnCode = - 1
116+
111117 # write header and preamble to errfile
112118 with open (errfile ,"w" ) as stderr :
113119 if len (header )> 0 : print (header ,file = stderr )
@@ -134,7 +140,7 @@ def test_plumed( executible, filename, header=[], printjson=False, jsondir="./"
134140 # compress both outfile and errtxtfile
135141 zip (outfile )
136142 zip (errtxtfile )
137- return plumed_out . returncode
143+ return returnCode
138144
139145def manage_incomplete_inputs ( inpt ) :
140146 """
0 commit comments