Skip to content

Commit

Permalink
Enforce tests execute ok (rscada#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
fredrik-sk committed Jul 1, 2020
1 parent d114d53 commit 42c9376
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions test/generate-xml.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
#
#------------------------------------------------------------------------------

NUMBER_OF_PARSING_ERRORS=0
FAILING_TESTS=failing_tests.txt
touch $FAILING_TESTS

# Check commandline parameter
if [ $# -ne 1 ]; then
echo "usage: $0 path_to_directory_with_xml_files"
Expand Down Expand Up @@ -64,6 +68,7 @@ generate_xml() {

# Check parsing result
if [ $result -ne 0 ]; then
NUMBER_OF_PARSING_ERRORS=$((NUMBER_OF_PARSING_ERRORS + 1))
echo "Unable to generate XML for $hexfile"
rm "$directory/$filename.$suffix.new"
return 1
Expand All @@ -81,14 +86,17 @@ generate_xml() {
;;
1)
# different -> print diff
echo "== $directory/$filename failed"
cat "$directory/$filename.$suffix.dif" && rm "$directory/$filename.$suffix.dif"
echo ""
echo "$filename" >> $FAILING_TESTS
;;
*)
# no old -> rename XML
echo "Create $filename.$suffix"
mv "$directory/$filename.$suffix.new" "$directory/$filename.$suffix"
rm "$directory/$filename.$suffix.dif"
echo "NEW FILE: $filename" >> $FAILING_TESTS
;;
esac

Expand All @@ -105,3 +113,20 @@ for hexfile in "$directory"/*.hex; do
generate_xml "$directory" "$hexfile" "normalized"
done

# Check the size of the file $FAILING_TESTS. Make sure to indicate failure.
if [ -s $FAILING_TESTS ]; then
echo "** There were errors in the following file(s):"
ls -l $FAILING_TESTS
cat $FAILING_TESTS
exit 1
else
rm $FAILING_TESTS
fi

# Check that there was exactly the correct number of files that failed to parse
EXPECTED_PARSE_ERRORS=4
if [ $NUMBER_OF_PARSING_ERRORS -ne $EXPECTED_PARSE_ERRORS ]; then
echo "** There were $NUMBER_OF_PARSING_ERRORS files that did not parse, expected $EXPECTED_PARSE_ERRORS files."
exit 1
fi
echo "** Tests executed successfull"

0 comments on commit 42c9376

Please sign in to comment.