Add autopkgtests to validate XMLs structure and avoid bugs like #862228
This commit is contained in:
Vendored
+1
@@ -2,6 +2,7 @@ desktop-base (10.0.0~exp1) UNRELEASED; urgency=medium
|
||||
|
||||
* Build with debhelper, bump compatibility level to 10, drop CDBS build
|
||||
dependency.
|
||||
* Add autopkgtests to validate XMLs structure and avoid bugs like #862228.
|
||||
|
||||
-- Aurélien COUDERC <zecoucou@free.fr> Mon, 30 Jan 2017 22:21:40 +0100
|
||||
|
||||
|
||||
Vendored
+2
@@ -0,0 +1,2 @@
|
||||
Tests: validate-xmls-lint, validate-svgs-xmllint
|
||||
Depends: libxml2-utils
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
dir_name=$(dirname $0)
|
||||
. ${dir_name}/xmllint-functions
|
||||
|
||||
XML_FILE_PATTERN="*.svg"
|
||||
XML_LINT_SUMMARY="svgs-xmllint-summary.csv"
|
||||
if [[ -n ${AUTOPKGTEST_ARTIFACTS} ]] ; then
|
||||
XML_LINT_SUMMARY="${AUTOPKGTEST_ARTIFACTS}/${XML_LINT_SUMMARY}"
|
||||
fi
|
||||
|
||||
|
||||
xml_lint_command="lint_xmls ${XML_FILE_PATTERN} ${XML_LINT_SUMMARY}"
|
||||
echo "$0: running '${xml_lint_command}'..."
|
||||
${xml_lint_command}
|
||||
xml_lint_result=$?
|
||||
|
||||
echo "$0: '${xml_lint_command}' returned ${xml_lint_result}"
|
||||
|
||||
|
||||
exit ${xml_lint_result}
|
||||
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
#!/bin/bash
|
||||
|
||||
dir_name=$(dirname $0)
|
||||
. ${dir_name}/xmllint-functions
|
||||
|
||||
XML_FILE_PATTERN="*.xml"
|
||||
XML_LINT_SUMMARY="xmls-lint-summary.csv"
|
||||
if [[ -n ${AUTOPKGTEST_ARTIFACTS} ]] ; then
|
||||
XML_LINT_SUMMARY="${AUTOPKGTEST_ARTIFACTS}/${XML_LINT_SUMMARY}"
|
||||
fi
|
||||
|
||||
|
||||
xml_lint_command="lint_xmls ${XML_FILE_PATTERN} ${XML_LINT_SUMMARY}"
|
||||
echo "$0: running '${xml_lint_command}'..."
|
||||
${xml_lint_command}
|
||||
xml_lint_result=$?
|
||||
|
||||
echo "$0: '${xml_lint_command}' returned ${xml_lint_result}"
|
||||
|
||||
|
||||
exit ${xml_lint_result}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
lint_xmls() {
|
||||
local xml_file_pattern=$1
|
||||
local xml_lint_summary=$2
|
||||
|
||||
if [ "$#" -ne 2 ] ; then
|
||||
echo "$0: wrong number of arguments."
|
||||
echo "Expected:"
|
||||
echo " $0 xml_file_pattern summary_file_name"
|
||||
return 255
|
||||
fi
|
||||
|
||||
echo "Running xmllint for pattern '${xml_file_pattern}'"
|
||||
echo "Current directory is '$(pwd)'"
|
||||
echo "Result will be stored in ${xml_lint_summary}"
|
||||
echo
|
||||
|
||||
echo "file,xmllint_status" > ${xml_lint_summary}
|
||||
|
||||
local files_list=$(find . -name "${xml_file_pattern}")
|
||||
local nb_files=$(echo "${files_list}" | wc -l)
|
||||
local nb_ok=0
|
||||
local nb_errors=0
|
||||
|
||||
echo "${nb_files} files will be checked"
|
||||
|
||||
while IFS= read -d $'\n' -r xml_file ; do
|
||||
echo "xmllinting file '${xml_file}'"
|
||||
xmllint --noout ${xml_file}
|
||||
local xmllint_result=$?
|
||||
echo "${xml_file},${xmllint_result}" >> ${xml_lint_summary}
|
||||
if [ ${xmllint_result} -eq 0 ] ; then
|
||||
echo "'${xml_file}' is OK"
|
||||
((nb_ok++))
|
||||
else
|
||||
echo "'${xml_file}' has errors"
|
||||
((nb_errors++))
|
||||
fi
|
||||
done <<< "${files_list}"
|
||||
|
||||
echo "Results of xmllint for pattern '${xml_file_pattern}'"
|
||||
echo " Checked: ${nb_files}"
|
||||
echo " OK: ${nb_ok}"
|
||||
echo " Errors: ${nb_errors}"
|
||||
|
||||
return ${nb_errors}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user