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
|
# Validate rule files
|
||||||
- make validateRules
|
- make validateRules
|
||||||
# check htmlreport stuff
|
# check htmlreport stuff
|
||||||
- ./htmlreport/test_htmlreport.py
|
- python2 htmlreport/test_htmlreport.py
|
||||||
|
- python3 htmlreport/test_htmlreport.py
|
||||||
- cd htmlreport
|
- cd htmlreport
|
||||||
- ./check.sh
|
- PYTHON=python2 ./check.sh
|
||||||
|
- PYTHON=python3 ./check.sh
|
||||||
- cd ../
|
- cd ../
|
||||||
# check if DESTDIR works TODO: actually execute this
|
# check if DESTDIR works TODO: actually execute this
|
||||||
- mkdir install_test
|
- mkdir install_test
|
||||||
|
|
|
@ -7,8 +7,12 @@
|
||||||
tidy_cmd='tidy -o /dev/null -eq'
|
tidy_cmd='tidy -o /dev/null -eq'
|
||||||
|
|
||||||
function validate_html {
|
function validate_html {
|
||||||
|
if [ ! -f "$1" ]; then
|
||||||
|
echo "File $1 does not exist!"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
set +e
|
set +e
|
||||||
${tidy_cmd} $1
|
${tidy_cmd} "$1"
|
||||||
tidy_status=$?
|
tidy_status=$?
|
||||||
set -e
|
set -e
|
||||||
if [ $tidy_status -eq 2 ]; then
|
if [ $tidy_status -eq 2 ]; then
|
||||||
|
@ -17,46 +21,59 @@ function validate_html {
|
||||||
fi
|
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"
|
echo -e "\n"
|
||||||
# Check HTML syntax
|
# Check HTML syntax
|
||||||
validate_html index.html
|
validate_html "$INDEX_HTML"
|
||||||
validate_html stats.html
|
validate_html "$STATS_HTML"
|
||||||
|
|
||||||
|
|
||||||
../cppcheck ../gui/test --enable=all --inconclusive --xml-version=2 2> gui_test.xml
|
../cppcheck ../gui/test --enable=all --inconclusive --xml-version=2 2> "$GUI_TEST_XML"
|
||||||
xmllint --noout gui_test.xml
|
xmllint --noout "$GUI_TEST_XML"
|
||||||
./cppcheck-htmlreport --file ./gui_test.xml --title "xml2 + inconclusive test" --report-dir .
|
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive test" --report-dir "$REPORT_DIR"
|
||||||
echo ""
|
echo ""
|
||||||
# Check HTML syntax
|
# Check HTML syntax
|
||||||
validate_html index.html
|
validate_html "$INDEX_HTML"
|
||||||
validate_html stats.html
|
validate_html "$STATS_HTML"
|
||||||
|
|
||||||
|
|
||||||
../cppcheck ../gui/test --enable=all --inconclusive --verbose --xml-version=2 2> gui_test.xml
|
../cppcheck ../gui/test --enable=all --inconclusive --verbose --xml-version=2 2> "$GUI_TEST_XML"
|
||||||
xmllint --noout gui_test.xml
|
xmllint --noout "$GUI_TEST_XML"
|
||||||
./cppcheck-htmlreport --file ./gui_test.xml --title "xml2 + inconclusive + verbose test" --report-dir .
|
$PYTHON cppcheck-htmlreport --file "$GUI_TEST_XML" --title "xml2 + inconclusive + verbose test" --report-dir "$REPORT_DIR"
|
||||||
echo -e "\n"
|
echo -e "\n"
|
||||||
# Check HTML syntax
|
# Check HTML syntax
|
||||||
validate_html index.html
|
validate_html "$INDEX_HTML"
|
||||||
validate_html stats.html
|
validate_html "$STATS_HTML"
|
||||||
|
|
||||||
|
|
||||||
../cppcheck --errorlist --inconclusive --xml-version=2 > errorlist.xml
|
../cppcheck --errorlist --inconclusive --xml-version=2 > "$ERRORLIST_XML"
|
||||||
xmllint --noout errorlist.xml
|
xmllint --noout "$ERRORLIST_XML"
|
||||||
./cppcheck-htmlreport --file ./errorlist.xml --title "errorlist" --report-dir .
|
$PYTHON cppcheck-htmlreport --file "$ERRORLIST_XML" --title "errorlist" --report-dir "$REPORT_DIR"
|
||||||
# Check HTML syntax
|
# Check HTML syntax
|
||||||
validate_html index.html
|
validate_html "$INDEX_HTML"
|
||||||
validate_html stats.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
|
../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
|
xmllint --noout "$UNMATCHEDSUPPR_XML"
|
||||||
./cppcheck-htmlreport --file ./unmatchedSuppr.xml --title "unmatched Suppressions" --report-dir=.
|
$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: variableScope*<" "$INDEX_HTML"
|
||||||
grep ">unmatchedSuppression</.*>information<.*>Unmatched suppression: uninitstring<" index.html
|
grep ">unmatchedSuppression</.*>information<.*>Unmatched suppression: uninitstring<" "$INDEX_HTML"
|
||||||
grep "notexisting" index.html
|
grep "notexisting" "$INDEX_HTML"
|
||||||
grep ">unmatchedSuppression<.*>information<.*>Unmatched suppression: \*<" index.html
|
grep ">unmatchedSuppression<.*>information<.*>Unmatched suppression: \*<" "$INDEX_HTML"
|
||||||
# Check HTML syntax
|
# Check HTML syntax
|
||||||
validate_html index.html
|
validate_html "$INDEX_HTML"
|
||||||
validate_html stats.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)
|
assert os.path.exists(xml_filename)
|
||||||
|
|
||||||
subprocess.check_call(
|
subprocess.check_call(
|
||||||
[HTML_REPORT_BIN,
|
[sys.executable, HTML_REPORT_BIN,
|
||||||
'--file=' + os.path.realpath(xml_filename),
|
'--file=' + os.path.realpath(xml_filename),
|
||||||
'--report-dir=' + os.path.realpath(output_directory)],
|
'--report-dir=' + os.path.realpath(output_directory)],
|
||||||
cwd=os.path.join(ROOT_DIR, 'htmlreport'))
|
cwd=os.path.join(ROOT_DIR, 'htmlreport'))
|
||||||
|
|
Loading…
Reference in New Issue