@@ -321,42 +321,49 @@ fn test_json_writer() {
321321 ) ;
322322}
323323
324- #[ test]
325- fn test_disallowed_in_qmd_fails ( ) {
324+ fn ensure_file_does_not_parse ( path : & std:: path:: Path ) {
325+ let markdown = std:: fs:: read_to_string ( path) . expect ( "Failed to read file" ) ;
326+ let mut parser = MarkdownParser :: default ( ) ;
327+ let input_bytes = markdown. as_bytes ( ) ;
328+ let tree = parser
329+ . parse ( input_bytes, None )
330+ . expect ( "Failed to parse input" ) ;
331+
332+ let errors = parse_is_good ( & tree) ;
333+ if errors. is_empty ( ) {
334+ panic ! (
335+ "File {} should not parse but it did: {:?}" ,
336+ path. display( ) ,
337+ errors
338+ ) ;
339+ }
340+ }
341+
342+ fn ensure_every_file_in_directory_does_not_parse ( pattern : & str ) {
326343 let mut file_count = 0 ;
327- for entry in glob ( "tests/pandoc-differences/disallowed-in-qmd/*.qmd" )
328- . expect ( "Failed to read glob pattern" )
329- {
344+ for entry in glob ( pattern) . expect ( "Failed to read glob pattern" ) {
330345 match entry {
331346 Ok ( path) => {
332347 eprintln ! ( "Opening file: {}" , path. display( ) ) ;
333- let markdown = std:: fs:: read_to_string ( & path) . expect ( "Failed to read file" ) ;
334-
335- // Parse with our parser
336- let mut parser = MarkdownParser :: default ( ) ;
337- let input_bytes = markdown. as_bytes ( ) ;
338- let tree = parser
339- . parse ( input_bytes, None )
340- . expect ( "Failed to parse input" ) ;
341-
342- let errors = parse_is_good ( & tree) ;
343- if errors. is_empty ( ) {
344- panic ! (
345- "File {} contains disallowed syntax but no parse errors were reported" ,
346- path. display( )
347- ) ;
348- }
348+ ensure_file_does_not_parse ( & path) ;
349349 file_count += 1 ;
350350 }
351351 Err ( e) => panic ! ( "Error reading glob entry: {}" , e) ,
352352 }
353353 }
354354 assert ! (
355355 file_count > 0 ,
356- "No files found in tests/pandoc-differences/disallowed-in-qmd directory"
356+ "No files found in directory matching pattern: {}" ,
357+ pattern
357358 ) ;
358359}
359360
361+ #[ test]
362+ fn test_disallowed_in_qmd_fails ( ) {
363+ ensure_every_file_in_directory_does_not_parse ( "tests/pandoc-differences/disallowed-in-qmd/*.qmd" ) ;
364+ ensure_every_file_in_directory_does_not_parse ( "tests/invalid-syntax/*.qmd" ) ;
365+ }
366+
360367#[ test]
361368fn test_do_not_smoke ( ) {
362369 let mut file_count = 0 ;
0 commit comments