diff options
| -rw-r--r-- | Makefile | 3 | ||||
| -rw-r--r-- | README | 2 | ||||
| -rwxr-xr-x | tests.sh | 43 |
3 files changed, 48 insertions, 0 deletions
@@ -138,6 +138,7 @@ help: " # For security reasons This file needs to be manually " \ " # reviewed manually before usage." \ "markdown # create markdown pages. To be done after reviewing links.txt." \ + "check # Run tests." \ serve: $(HAUNT) serve -w -p $(HAUNT_PORT) @@ -155,3 +156,5 @@ website.tar.gz: build index.html \ --transform="s#^site#web#" \ --transform="s#^pages/img/#web/img/#" +check: build + ./tests.sh @@ -13,6 +13,8 @@ To generate this website you will need guix and curl. The rest of the dependencies are taken care of by Guix. Once you installed Guix you need to run 'guix pull' to have the latest revision. +To run the tests (with make check) you will need shellcheck. + Usage ===== diff --git a/tests.sh b/tests.sh new file mode 100755 index 0000000..da8f49a --- /dev/null +++ b/tests.sh @@ -0,0 +1,43 @@ +#!/usr/bin/env bash +# +# Copyright (C) 2024 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. + +nr_errors=0 + +# Test generated HTML files. +for file in site/*.html ; do + # Test for unknown characters. + if grep '??' "${file}" > /dev/null ; then + echo "[ !! ] ${file}" + nr_errors=$((nr_errors + 1)) + else + echo "[ OK ] ${file}" + fi +done + +# Test shell scripts. +if shellcheck -x tests.sh ; then + echo "[ OK ] tests.sh" +else + nr_errors=$((nr_errors + 1)) + echo "[ !! ] tests.sh" +fi + +# Fail if some errors were found. +echo "${nr_errors} errors found." +if [ ${nr_errors} -gt 0 ] ; then + exit 1 +fi |
