From 758775ac92a11f7d378287ef6c65285dd44c3a6f Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sun, 20 Sep 2020 11:47:04 +0200 Subject: [PATCH] Cmake export xhtml tests: load dtd if checking ouput with xmllint --- development/autotests/examineXmllintOutput.pl | 19 ++++++++ development/autotests/export.cmake | 47 ++++++++++--------- development/autotests/invertedTests | 6 --- 3 files changed, 44 insertions(+), 28 deletions(-) diff --git a/development/autotests/examineXmllintOutput.pl b/development/autotests/examineXmllintOutput.pl index 36007e2462..5c79431340 100755 --- a/development/autotests/examineXmllintOutput.pl +++ b/development/autotests/examineXmllintOutput.pl @@ -12,6 +12,7 @@ my %errors = (); if (open(FI, $file)) { my $line = 0; + my %entities = (); my $saxchartoprint = 0; while(my $l = ) { $line++; @@ -66,6 +67,21 @@ if (open(FI, $file)) { $saxchartoprint = 3; } } + elsif ($l =~ /: parser error :\s+(.*)$/) { + my $err = $1; + $errors{$err} = $errmsg; + if ($errmsg =~ /Entity\s+'([a-zA-Z0-9]+)'\s+not defined/) { + my $entity = $1; + if (! defined($entities{$entity})) { + $entities{$entity} = 1; + print "$errmsg\n"; + } + } + else { + print "$l\n"; + die("Unknown error $l"); + } + } elsif ($saxchartoprint > 0) { $saxchartoprint--; if ($l =~ /^SAX.characters\(([^\)]+)\)/) { @@ -74,4 +90,7 @@ if (open(FI, $file)) { } } } +if (keys %errors) { + exit(1); +} exit(0); diff --git a/development/autotests/export.cmake b/development/autotests/export.cmake index 55ca7a7102..4c77f06bb4 100755 --- a/development/autotests/export.cmake +++ b/development/autotests/export.cmake @@ -229,28 +229,29 @@ else() else() message(STATUS "Expected result file \"${result_file_name}\" exists") if (extension MATCHES "^x(ht)?ml$") - if (format MATCHES "xhtml") - set(xmllint_params --sax --html --valid) - set(executable_ ${XMLLINT_EXECUTABLE}) - else() - set(xmllint_params) - set(executable_ ${PERL_EXECUTABLE} "${TOP_SRC_DIR}/development/autotests/filterXml4Sax.pl") - # Check with perl xml-parser - # needs XML::Parser module - message(STATUS "Calling ${PERL_EXECUTABLE} \"${TOP_SRC_DIR}/development/autotests/xmlParser.pl\" \"${result_file_name}\"") - execute_process( - COMMAND ${PERL_EXECUTABLE} "${TOP_SRC_DIR}/development/autotests/xmlParser.pl" "${result_file_name}" - OUTPUT_VARIABLE parserout - ERROR_VARIABLE parsererr - RESULT_VARIABLE _err - ) - if (_err) - message(STATUS "${parsererr}") - endif() - Summary(_err "Checking \"${result_file_name}\" with xmlParser.pl") - endif() + if (format MATCHES "xhtml") + set(xmllint_params --loaddtd --noout) + set(executable_ ${XMLLINT_EXECUTABLE}) + else() + set(xmllint_params) + set(executable_ ${PERL_EXECUTABLE} "${TOP_SRC_DIR}/development/autotests/filterXml4Sax.pl") + # Check with perl xml-parser + # needs XML::Parser module + message(STATUS "Calling ${PERL_EXECUTABLE} \"${TOP_SRC_DIR}/development/autotests/xmlParser.pl\" \"${result_file_name}\"") + execute_process( + COMMAND ${PERL_EXECUTABLE} "${TOP_SRC_DIR}/development/autotests/xmlParser.pl" "${result_file_name}" + OUTPUT_VARIABLE parserout + ERROR_VARIABLE parsererr + RESULT_VARIABLE _err + ) + if (_err) + message(STATUS "${parsererr}") + endif() + Summary(_err "Checking \"${result_file_name}\" with xmlParser.pl") + endif() if (XMLLINT_EXECUTABLE) - message(STATUS "Calling: " ${executable_} ${xmllint_params} " ${result_file_name}") + string(REPLACE ";" " " xmllint_params2 " ${xmllint_params}") + message(STATUS "Calling: " ${executable_} ${xmllint_params2} " ${WORKDIR}/${result_file_name}") # check the created xhtml file execute_process( COMMAND ${executable_} ${xmllint_params} "${result_file_name}" @@ -260,13 +261,15 @@ else() file(WRITE "${result_file_name}.sax_out" ${xmlout}) Summary(_err "Checking \"${result_file_name}\" with ${XMLLINT_EXECUTABLE}") if (NOT _err) - # check if sax-parser output contains error messages + # check if parser output contains error messages message(STATUS "Check the output: ${PERL_EXECUTABLE} ${TOP_SRC_DIR}/development/autotests/examineXmllintOutput.pl") execute_process( COMMAND ${PERL_EXECUTABLE} "${TOP_SRC_DIR}/development/autotests/examineXmllintOutput.pl" "${result_file_name}.sax_out" OUTPUT_VARIABLE xmlout RESULT_VARIABLE _err) Summary(_err "Parse messages of ${XMLLINT_EXECUTABLE} for errors") + else() + message(STATUS "Errors from xmllint: ${xmlerr}") endif() if (NOT _err) if (NOT "${xmlout}" STREQUAL "") diff --git a/development/autotests/invertedTests b/development/autotests/invertedTests index d414931463..bf410aa8eb 100644 --- a/development/autotests/invertedTests +++ b/development/autotests/invertedTests @@ -116,12 +116,6 @@ export/export/latex/lyxbugs/[0-9].* # (For some reason, the false positive error is not thrown with PDF (luatex).) #export/examples/sr/Modules/Braille_(dvi3|pdf4)_systemF -#10355 xmllint detects failures -export/doc/attic/eu_UserGuide_xhtml -export/doc/(es|ja)/UserGuide_xhtml -export/examples/External_Material/Spreadsheet_xhtml -export/export/WrongDfnTagHandling_xhtml - #11455 "Unable to process argument!" with multiple 1.6.x roundtrips export/templates/Articles/IEEE_Transactions_Journal_lyx16