Cmake url tests: Handle some special chars in urls.

This commit is contained in:
Kornel Benko 2015-11-26 14:31:15 +01:00
parent 21c265addb
commit f3989f1e3a
2 changed files with 16 additions and 3 deletions

View File

@ -19,7 +19,7 @@ endforeach()
# Define the perl-script running the actual test
set(SEARCH_URL_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/search_url.pl")
set(GET_TRANSLATORS_SCRIP "${CMAKE_CURRENT_SOURCE_DIR}/getTranslators.pl")
set(GET_TRANSLATORS_SCRIPT "${CMAKE_CURRENT_SOURCE_DIR}/getTranslators.pl")
# Test used and as accessible expected urls
add_test(NAME "check_accessible_urls"
@ -52,12 +52,15 @@ add_test(NAME "check_invalid_urls"
"revertedURLS=${CMAKE_CURRENT_SOURCE_DIR}/knownInvalidURLS"
"summaryFile=${TOP_BINARY_DIR}/Testing/Temporary/LastFailedKnownInvalidURLS.log")
set(URL_TEST_NAMES "check_accessible_urls" "check_inaccessible_urls" "check_invalid_urls")
add_test(NAME "check_translators"
WORKING_DIRECTORY "${TOP_BINARY_DIR}"
COMMAND ${PERL_EXECUTABLE} "${GET_TRANSLATORS_SCRIP}")
COMMAND ${PERL_EXECUTABLE} "${GET_TRANSLATORS_SCRIPT}")
set_tests_properties("check_accessible_urls" "check_inaccessible_urls" "check_invalid_urls" "check_translators"
set_tests_properties(${URL_TEST_NAMES}
PROPERTIES RESOURCE_LOCK "url.lock" LABELS "url")
set_tests_properties("check_translators"
PROPERTIES RESOURCE_LOCK "url.lock")
settestlabel("check_inaccessible_urls" "reverted")
settestlabel("check_invalid_urls" "reverted")

View File

@ -48,6 +48,7 @@ setlocale(LC_MESSAGES, "en_US.UTF-8");
# Prototypes
sub printNotUsedURLS($\%);
sub replaceSpecialChar($);
sub readUrls($\%);
sub parse_file($ );
sub handle_url($$$ );
@ -199,6 +200,13 @@ sub printNotUsedURLS($\%)
}
}
sub replaceSpecialChar($)
{
my ($l) = @_;
$l =~ s/\\SpecialChar(NoPassThru)?\s*(TeX|LaTeX|LyX)[\s]?/\2/;
return($l);
}
sub readUrls($\%)
{
my ($file, $rUrls) = @_;
@ -209,6 +217,7 @@ sub readUrls($\%)
$line++;
$l =~ s/[\r\n]+$//; # remove eol
$l =~ s/\s*\#.*$//; # remove comment
$l = &replaceSpecialChar($l);
next if ($l eq "");
if (! defined($rUrls->{$l} )) {
$rUrls->{$l} = {$file => $line, count => 1};
@ -272,6 +281,7 @@ sub handle_url($$$)
{
my($url, $f, $line) = @_;
$url = &replaceSpecialChar($url);
if(!defined($URLS{$url})) {
$URLS{$url} = {};
}