travis: Test htmlreport with python2 and python3 (#2862)
This commit is contained in:
parent
f70e8de315
commit
c6036f8704
|
@ -65,9 +65,11 @@ matrix:
|
|||
# Validate rule files
|
||||
- make validateRules
|
||||
# check htmlreport stuff
|
||||
- ./htmlreport/test_htmlreport.py
|
||||
- python2 htmlreport/test_htmlreport.py
|
||||
- python3 htmlreport/test_htmlreport.py
|
||||
- cd htmlreport
|
||||
- ./check.sh
|
||||
- PYTHON=python2 ./check.sh
|
||||
- PYTHON=python3 ./check.sh
|
||||
- cd ../
|
||||
# check if DESTDIR works TODO: actually execute this
|
||||
- mkdir install_test
|
||||
|
|
|
@ -7,8 +7,12 @@
|
|||
tidy_cmd='tidy -o /dev/null -eq'
|
||||
|
||||
function validate_html {
|
||||
if [ ! -f "$1" ]; then
|
||||
echo "File $1 does not exist!"
|
||||
exit 1
|
||||
fi
|
||||
set +e
|
||||
${tidy_cmd} $1
|
||||
${tidy_cmd} "$1"
|
||||
tidy_status=$?
|
||||
set -e
|
||||
if [ $tidy_status -eq 2 ]; then
|
||||
|
@ -17,46 +21,59 @@ function validate_html {
|
|||
fi
|
||||
}
|
||||
|
||||
./cppcheck-htmlreport --file ../gui/test/data/xmlfiles/xmlreport_v2.xml --title "xml2 test" --report-dir . --source-dir ../test/
|
||||
if [ -z "$PYTHON" ]; then
|
||||
PYTHON=python
|
||||
fi
|
||||
|
||||
REPORT_DIR=$(mktemp -d -t htmlreport-XXXXXXXXXX)
|
||||
INDEX_HTML="$REPORT_DIR/index.html"
|
||||
STATS_HTML="$REPORT_DIR/stats.html"
|
||||
GUI_TEST_XML="$REPORT_DIR/gui_test.xml"
|
||||
ERRORLIST_XML="$REPORT_DIR/errorlist.xml"
|
||||
UNMATCHEDSUPPR_XML="$REPORT_DIR/unmatchedSuppr.xml"
|
||||
|
||||
$PYTHON cppcheck-htmlreport --file ../gui/test/data/xmlfiles/xmlreport_v2.xml --title "xml2 test" --report-dir "$REPORT_DIR" --source-dir ../test/
|
||||
echo -e "\n"
|
||||
# Check HTML syntax
|
||||
validate_html index.html
|
||||
validate_html stats.html
|
||||
validate_html "$INDEX_HTML"
|
||||
validate_html "$STATS_HTML"
|
||||
|
||||
|
||||
../cppcheck ../gui/test --enable=all --inconclusive --xml-version=2 2> gui_test.xml
|
||||
xmllint --noout gui_test.xml
|
||||
./cppcheck-htmlreport --file ./gui_test.xml --title "xml2 + inconclusive test" --report-dir .
|
||||
../cppcheck ../gui/test --enable=all --inconclusive --xml-version=2 2> "$GUI_TEST_XML"
|
||||
xmllint --noout "$GUI_TEST_XML"
|
||||
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive test" --report-dir "$REPORT_DIR"
|
||||
echo ""
|
||||
# Check HTML syntax
|
||||
validate_html index.html
|
||||
validate_html stats.html
|
||||
validate_html "$INDEX_HTML"
|
||||
validate_html "$STATS_HTML"
|
||||
|
||||
|
||||
../cppcheck ../gui/test --enable=all --inconclusive --verbose --xml-version=2 2> gui_test.xml
|
||||
xmllint --noout gui_test.xml
|
||||
./cppcheck-htmlreport --file ./gui_test.xml --title "xml2 + inconclusive + verbose test" --report-dir .
|
||||
../cppcheck ../gui/test --enable=all --inconclusive --verbose --xml-version=2 2> "$GUI_TEST_XML"
|
||||
xmllint --noout "$GUI_TEST_XML"
|
||||
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive + verbose test" --report-dir "$REPORT_DIR"
|
||||
echo -e "\n"
|
||||
# Check HTML syntax
|
||||
validate_html index.html
|
||||
validate_html stats.html
|
||||
validate_html "$INDEX_HTML"
|
||||
validate_html "$STATS_HTML"
|
||||
|
||||
|
||||
../cppcheck --errorlist --inconclusive --xml-version=2 > errorlist.xml
|
||||
xmllint --noout errorlist.xml
|
||||
./cppcheck-htmlreport --file ./errorlist.xml --title "errorlist" --report-dir .
|
||||
../cppcheck --errorlist --inconclusive --xml-version=2 > "$ERRORLIST_XML"
|
||||
xmllint --noout "$ERRORLIST_XML"
|
||||
$PYTHON cppcheck-htmlreport --file "$ERRORLIST_XML" --title "errorlist" --report-dir "$REPORT_DIR"
|
||||
# Check HTML syntax
|
||||
validate_html index.html
|
||||
validate_html stats.html
|
||||
validate_html "$INDEX_HTML"
|
||||
validate_html "$STATS_HTML"
|
||||
|
||||
|
||||
../cppcheck ../samples/memleak/good.c ../samples/resourceLeak/good.c --xml-version=2 --enable=information --suppressions-list=test_suppressions.txt --xml 2> unmatchedSuppr.xml
|
||||
xmllint --noout unmatchedSuppr.xml
|
||||
./cppcheck-htmlreport --file ./unmatchedSuppr.xml --title "unmatched Suppressions" --report-dir=.
|
||||
grep "unmatchedSuppression<.*>information<.*>Unmatched suppression: variableScope*<" index.html
|
||||
grep ">unmatchedSuppression</.*>information<.*>Unmatched suppression: uninitstring<" index.html
|
||||
grep "notexisting" index.html
|
||||
grep ">unmatchedSuppression<.*>information<.*>Unmatched suppression: \*<" index.html
|
||||
../cppcheck ../samples/memleak/good.c ../samples/resourceLeak/good.c --xml-version=2 --enable=information --suppressions-list=test_suppressions.txt --xml 2> "$UNMATCHEDSUPPR_XML"
|
||||
xmllint --noout "$UNMATCHEDSUPPR_XML"
|
||||
$PYTHON cppcheck-htmlreport --file "$UNMATCHEDSUPPR_XML" --title "unmatched Suppressions" --report-dir="$REPORT_DIR"
|
||||
grep "unmatchedSuppression<.*>information<.*>Unmatched suppression: variableScope*<" "$INDEX_HTML"
|
||||
grep ">unmatchedSuppression</.*>information<.*>Unmatched suppression: uninitstring<" "$INDEX_HTML"
|
||||
grep "notexisting" "$INDEX_HTML"
|
||||
grep ">unmatchedSuppression<.*>information<.*>Unmatched suppression: \*<" "$INDEX_HTML"
|
||||
# Check HTML syntax
|
||||
validate_html index.html
|
||||
validate_html stats.html
|
||||
validate_html "$INDEX_HTML"
|
||||
validate_html "$STATS_HTML"
|
||||
|
||||
rm -rf "$REPORT_DIR"
|
||||
|
|
|
@ -98,7 +98,7 @@ def runCheck(source_filename=None, xml_version='1', xml_filename=None):
|
|||
assert os.path.exists(xml_filename)
|
||||
|
||||
subprocess.check_call(
|
||||
[HTML_REPORT_BIN,
|
||||
[sys.executable, HTML_REPORT_BIN,
|
||||
'--file=' + os.path.realpath(xml_filename),
|
||||
'--report-dir=' + os.path.realpath(output_directory)],
|
||||
cwd=os.path.join(ROOT_DIR, 'htmlreport'))
|
||||
|
|
Loading…
Reference in New Issue