44Does 3 things which can either be done independently or
55as a pipeline:
66
7- 1. Extracts tests from static mdoc files and docstrings from Mathics built-in functions
7+ 1. Extracts tests and runs them from static mdoc files and docstrings from Mathics built-in functions
882. Creates/updates internal documentation data
993. It writes the LaTeX file containing the entire User Manual
1010"""
@@ -148,12 +148,20 @@ def fail(why):
148148
149149
150150def test_tests (
151- tests , index , quiet = False , stop_on_failure = False , start_at = 0 , max_tests = MAX_TESTS
151+ tests ,
152+ index ,
153+ quiet = False ,
154+ stop_on_failure = False ,
155+ start_at = 0 ,
156+ max_tests = MAX_TESTS ,
157+ excludes = [],
152158):
153159 definitions .reset_user_definitions ()
154160 total = failed = skipped = 0
155161 failed_symbols = set ()
156162 section = tests .section
163+ if section in excludes :
164+ return total , failed , len (tests .tests ), failed_symbols , index
157165 count = 0
158166 for subindex , test in enumerate (tests .tests ):
159167 index += 1
@@ -177,21 +185,22 @@ def test_tests(
177185 return total , failed , skipped , failed_symbols , index
178186
179187
180- def create_output (tests , output_tex ):
188+ # FIXME: move this to common routine
189+ def create_output (tests , output , format = "tex" ):
181190 definitions .reset_user_definitions ()
182191 for test in tests .tests :
183192 if test .private :
184193 continue
185194 key = test .key
186195 evaluation = Evaluation (
187- definitions , format = "tex" , catch_interrupt = False , output = TestOutput ()
196+ definitions , format = format , catch_interrupt = False , output = TestOutput ()
188197 )
189198 result = evaluation .parse_evaluate (test .test )
190199 if result is None :
191200 result = []
192201 else :
193202 result = [result .get_data ()]
194- output_tex [key ] = {
203+ output [key ] = {
195204 "query" : test .test ,
196205 "results" : result ,
197206 }
@@ -245,13 +254,13 @@ def test_all(
245254 stop_on_failure = False ,
246255 start_at = 0 ,
247256 count = MAX_TESTS ,
248- xmldatafolder = None ,
249257 texdatafolder = None ,
250258 doc_even_if_error = False ,
259+ excludes = [],
251260):
252261 global documentation
253262 if not quiet :
254- print ("Testing %s" % version_string )
263+ print (f "Testing { version_string } " )
255264
256265 if generate_output :
257266 if texdatafolder is None :
@@ -260,7 +269,6 @@ def test_all(
260269 index = 0
261270 total = failed = skipped = 0
262271 failed_symbols = set ()
263- output_xml = {}
264272 output_tex = {}
265273 for tests in documentation .get_tests ():
266274 sub_total , sub_failed , sub_skipped , symbols , index = test_tests (
@@ -270,6 +278,7 @@ def test_all(
270278 stop_on_failure = stop_on_failure ,
271279 start_at = start_at ,
272280 max_tests = count ,
281+ excludes = excludes ,
273282 )
274283 if generate_output :
275284 create_output (tests , output_tex )
@@ -334,7 +343,7 @@ def extract_doc_from_source(quiet=False, reload=False):
334343 """
335344 if not quiet :
336345 print (f"Extracting internal doc data for { version_string } " )
337- print (f "This may take a while..." )
346+ print ("This may take a while..." )
338347
339348 try :
340349 output_tex = load_doc_data () if reload else {}
@@ -385,6 +394,15 @@ def main():
385394 help = "only test SECTION(s). "
386395 "You can list multiple sections by adding a comma (and no space) in between section names." ,
387396 )
397+ parser .add_argument (
398+ "--exclude" ,
399+ "-X" ,
400+ default = "" ,
401+ dest = "exclude" ,
402+ metavar = "SECTION" ,
403+ help = "excude SECTION(s). "
404+ "You can list multiple sections by adding a comma (and no space) in between section names." ,
405+ )
388406 parser .add_argument (
389407 "--logfile" ,
390408 "-f" ,
@@ -497,6 +515,7 @@ def main():
497515 reload = False ,
498516 )
499517 else :
518+ excludes = set (args .exclude .split ("," ))
500519 start_at = args .skip + 1
501520 start_time = datetime .now ()
502521 test_all (
@@ -506,6 +525,7 @@ def main():
506525 start_at = start_at ,
507526 count = args .count ,
508527 doc_even_if_error = args .keep_going ,
528+ excludes = excludes ,
509529 )
510530 end_time = datetime .now ()
511531 print ("Tests took " , end_time - start_time )
0 commit comments