Cmake export xhtml tests: load dtd if checking ouput with xmllint

This commit is contained in:
Kornel Benko 2020-09-20 11:47:04 +02:00
parent b814c4fda7
commit 758775ac92
3 changed files with 44 additions and 28 deletions

View File

@ -12,6 +12,7 @@ my %errors = ();
if (open(FI, $file)) {
my $line = 0;
my %entities = ();
my $saxchartoprint = 0;
while(my $l = <FI>) {
$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);

View File

@ -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 "")

View File

@ -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