hurl/integration/report.sh

59 lines
1.4 KiB
Bash
Raw Normal View History

2020-11-08 19:52:33 +03:00
#!/bin/bash
# Generate a unique html report
# Each hurl file will be run successively, result is appended to the same json file
set +e
2021-11-26 22:22:57 +03:00
rm -rf build
mkdir build
export HURL_name=Bob
2022-02-05 02:08:55 +03:00
# read options
# params:
# options_file optional filename
function read_options() {
file=$1
if test -f "$file"; then
while read -r option ; do
if [[ $option =~ " " ]]; then
echo -n " '$option'"
else
echo -n " $option"
fi
done < "$options_file"
fi
}
find tests_{ok,failed} -name "*.hurl" | sort | while read -r hurl_file; do
2022-02-05 02:08:55 +03:00
options_file="${hurl_file%.*}.options"
options="--report-html build/html --report-junit build/tests.xml --json $(read_options "$options_file")"
cmd="hurl $hurl_file $options"
2020-11-08 19:52:33 +03:00
echo "$cmd"
2022-02-05 02:08:55 +03:00
echo "$cmd" | sh >> "build/tests.json"
2020-11-08 19:52:33 +03:00
exit_code=$?
2021-11-26 22:22:57 +03:00
if [[ "$exit_code" != 0 && "$exit_code" != 3 && "$exit_code" != 4 ]]; then
echo "unexpected exit code $exit_code"
exit 1
2020-11-08 19:52:33 +03:00
fi
2021-11-26 22:22:57 +03:00
done
2022-02-05 02:08:55 +03:00
set -e
total=$(find tests_{ok,failed} -name '*.hurl' | wc -l)
2022-02-05 02:08:55 +03:00
total_in_json=$( wc -l < build/tests.json)
total_in_xml=$(xmllint --xpath '//testcase' - < build/tests.xml| grep -c 'testcase id')
echo "Total Number of tests: $total"
if [[ "$total_in_json" -ne "$total" ]] ; then
echo "Number of tests in JSON do not match!"
exit 1
fi
if [[ "$total_in_xml" -ne "$total" ]] ; then
echo "Number of tests in XML do not match!"
exit 1
fi
2021-11-26 22:22:57 +03:00
2020-11-08 19:52:33 +03:00