@@ -51,7 +51,7 @@ def getPlumedSyntax( plumedexe ) :
5151 raise InvalidJSONError (ve )
5252 return keyword_dict
5353
54- def test_and_get_html ( inpt , name , actions = set ({}) ) :
54+ def test_and_get_html ( inpt , name , actions = set ({}), test_plumed_kwargs = {} ) :
5555 """
5656 Test if the plumed input is broken and generate the html syntax
5757
@@ -75,15 +75,15 @@ def test_and_get_html( inpt, name, actions=set({}) ) :
7575 iff .write (test_inpt + "\n " )
7676 iff .close ()
7777 # Now do the test
78- broken = test_plumed ( "plumed" , filename , header = "" , printjson = True )
78+ broken = test_plumed ( "plumed" , filename , header = "" , printjson = True , ** test_plumed_kwargs )
7979 # Retrieve the html that is output by plumed
8080 html = get_html ( inpt , filename , filename , ("master" ,), (broken ,), ("plumed" ,), actions = actions )
8181 # Remove the tempory files that we created
8282 if not keepfile : os .remove (filename )
8383
8484 return html
8585
86- def test_plumed ( executible , filename , header = [] , printjson = False , jsondir = "./" , cmdTimeout :"None|float" = None , ghmarkdown = True ) :
86+ def test_plumed ( executible , filename , header = "" , printjson = False , jsondir = "./" , cmdTimeout :"None|float" = None , ghmarkdown = True ) :
8787 """
8888 Test if plumed can parse this input file
8989
@@ -136,7 +136,8 @@ def test_plumed( executible, filename, header=[], printjson=False, jsondir="./",
136136
137137 # write header and preamble to errfile
138138 with open (errfile ,"w" ) as stderr :
139- if len (header )> 0 : print (header ,file = stderr )
139+ if len (header )> 0 :
140+ print (header ,file = stderr )
140141 print ("Stderr for source: " ,re .sub ("^data/" ,"" ,filename )," " ,file = stderr )
141142 print ("Download: [zipped raw stdout](" + plumed_file + "." + executible + ".stdout.txt.zip) - [zipped raw stderr](" + plumed_file + "." + executible + ".stderr.txt.zip) " ,file = stderr )
142143 if ghmarkdown : print ("{% raw %}\n <pre style=\" overflow:scroll;\" >" ,file = stderr )
@@ -449,7 +450,7 @@ def get_html( inpt, name, outloc, tested, broken, plumedexe, usejson=None, maxch
449450 else : raise Exception ("Could not find toggler command for " + val )
450451 return html
451452
452- def get_mermaid ( executible , inpt , force ) :
453+ def get_mermaid ( executible , inpt , force , test_plumed_kwargs = {} ) :
453454 """
454455 Generate the mermaid graph showing how data passes through PLUMED input file
455456
@@ -462,7 +463,7 @@ def get_mermaid( executible, inpt, force ) :
462463 iff .write (inpt + "\n " )
463464 iff .close ()
464465 # Now check the input is OK
465- broken = test_plumed ( executible , "mermaid_plumed.dat" , header = "" )
466+ broken = test_plumed ( executible , "mermaid_plumed.dat" ,** test_plumed_kwargs )
466467 if broken != 0 : raise Exception ("invalid plumed input file -- cannot create mermaid graph" )
467468 # Run mermaid
468469 cmd = [executible , 'show_graph' , '--plumed' , 'mermaid_plumed.dat' , '--out' , 'mermaid.md' ]
@@ -657,7 +658,7 @@ def compare_to_reference( output, reference ) :
657658
658659 return True
659660
660- def processMarkdown ( filename , plumedexe , plumed_names , actions , jsondir = "./" , ghmarkdown = True ) :
661+ def processMarkdown ( filename , plumedexe , plumed_names , actions , jsondir = "./" , ghmarkdown = True , test_plumed_kwargs = {} ) :
661662 """
662663 Process a markdown file that contains PLUMED input files using PlumedtoHTML
663664
@@ -667,6 +668,7 @@ def processMarkdown( filename, plumedexe, plumed_names, actions, jsondir="./", g
667668 plumed_names -- the names of the plumed executibles to use in the badges
668669 actions -- names of actions used in the plumed inputs in this markdown file
669670 jsondir -- The directory in which to output the files containing the expansions of the shortcuts and the value dictionaries
671+ test_plumed_kwargs -- a dictionary of extra keywords to pass to the test_plumed utility, only "header" and "cmdTimeout" works
670672 """
671673 if not os .path .exists (filename ) :
672674 raise RuntimeError ("Found no file called " + filename + " in lesson" )
@@ -675,10 +677,13 @@ def processMarkdown( filename, plumedexe, plumed_names, actions, jsondir="./", g
675677 inp = f .read ()
676678
677679 with open ( filename , "w+" ) as ofile :
678- ninputs , nfail = processMarkdownString ( inp , filename , plumedexe , plumed_names , actions , ofile , jsondir , ghmarkdown )
680+ ninputs , nfail = processMarkdownString ( inp , filename , plumedexe , plumed_names ,
681+ actions , ofile , jsondir , ghmarkdowni , test_plumed_kwargs = test_plumed_kwargs )
679682 return ninputs , nfail
680683
681- def processMarkdownString ( inp , filename , plumedexe , plumed_names , actions , ofile , jsondir = "./" , ghmarkdown = True , checkaction = "ignore" , checkactionkeywords = set ({}) ) :
684+ def processMarkdownString ( inp , filename , plumedexe , plumed_names , actions , ofile ,
685+ jsondir = "./" , ghmarkdown = True , checkaction = "ignore" , checkactionkeywords = set ({}),
686+ test_plumed_kwargs = {}) :
682687 """
683688 Process a string of markdown that contains LUMED input files using PlumedtoHTML
684689
@@ -691,6 +696,7 @@ def processMarkdownString( inp, filename, plumedexe, plumed_names, actions, ofil
691696 dirname -- the directory in which to find solution files
692697 ofile -- the file on which to output the processed markdown
693698 jsondir -- The directory in which to output the files containing the expansions of the shortcuts and the value dictionaries
699+ test_plumed_kwargs -- a dictionary of extra keywords to pass to the test_plumed utility, only "header" and "cmdTimeout" works
694700 """
695701 dirname = os .path .dirname (filename )
696702 if dirname == "" : dirname = "."
@@ -782,12 +788,17 @@ def processMarkdownString( inp, filename, plumedexe, plumed_names, actions, ofil
782788 # PlumedToHTML finds them when we do get_html (i.e. these will be in
783789 # the data directory where the calculation is run)
784790 if incomplete :
785- success [i ]= test_plumed (plumedexe [i ], solutionfile , ghmarkdown = ghmarkdown )
791+ success [i ]= test_plumed (plumedexe [i ], solutionfile , ghmarkdown = ghmarkdown ,
792+ ** test_plumed_kwargs )
786793 else :
787794 success [i ]= test_plumed (plumedexe [i ], solutionfile ,
788- printjson = True , jsondir = jsondir , ghmarkdown = ghmarkdown )
795+ printjson = True , jsondir = jsondir , ghmarkdown = ghmarkdown ,
796+ ** test_plumed_kwargs )
789797 else :
790- success [i ]= test_plumed ( plumedexe [i ], solutionfile , ghmarkdown = ghmarkdown )
798+ success [i ]= test_plumed ( plumedexe [i ],
799+ solutionfile ,
800+ ghmarkdown = ghmarkdown ,
801+ ** test_plumed_kwargs ,)
791802 if (success [i ]!= 0 and success [i ]!= "custom" ) : nfail [i ] = nfail [i ] + 1
792803 # Use PlumedToHTML to create the input with all the bells and whistles
793804 html = get_html (plumed_inp ,
0 commit comments