test-documentation: Factor out the terminal goo for coloring messages.

This commit is contained in:
Greg Price 2018-01-09 10:15:08 -08:00
parent f1f5b25969
commit 618beb7110
1 changed files with 7 additions and 9 deletions

View File

@ -1,6 +1,10 @@
#!/usr/bin/env bash
set -e
color_message () {
local color_code="$1" message="$2"
echo -e "\e[${color_code}m${message}\e[0m"
}
case $1 in
-h|--help)
@ -22,22 +26,16 @@ rm -rf _build
# The crawler would take a very long time to finish and TravisCI would fail as a result.
sphinx-build -j8 -b html -d _build/doctrees -D html_theme_options.collapse_navigation=True . _build/html
echo -en "\033[0;94m"
echo "Testing links in documentation..."
echo -en "\033[0m"
color_message 94 "Testing links in documentation..."
cd ../tools/documentation_crawler
set +e
scrapy crawl_with_status documentation_crawler $loglevel
result=$?
if [ "$result" = 1 ]; then
echo -en "\033[0;91m"
echo "Failed!"
echo -en "\033[0m"
color_message 91 "Failed!"
exit 1
else
echo -en "\033[0;92m"
echo "Passed!"
echo -en "\033[0m"
color_message 92 "Passed!"
exit 0
fi