[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v1 18/18] website-build: check.sh: start adding tests for sit
From: |
Adrien 'neox' Bourmault |
Subject: |
Re: [PATCH v1 18/18] website-build: check.sh: start adding tests for site/. |
Date: |
Mon, 27 May 2024 15:21:50 +0200 |
User-agent: |
Evolution 3.48.4 |
Le samedi 25 mai 2024 à 20:25 +0200, Denis 'GNUtoo' Carikli a écrit :
> Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
> ---
> website-build/Makefile.am | 17 ++++++++++--
> website-build/check.sh | 58 +++++++++++++++++++++++++++++++++------
> 2 files changed, 63 insertions(+), 12 deletions(-)
>
> diff --git a/website-build/Makefile.am b/website-build/Makefile.am
> index 51879e2..62a001a 100644
> --- a/website-build/Makefile.am
> +++ b/website-build/Makefile.am
> @@ -49,21 +49,32 @@ build:
> endif
>
> if WANT_GUIX
> -check: website.tar.gz
> +check: build website.tar.gz
> + rm -rf site/
> + mkdir -p site/software/gnuboot/
> + tar xf website.tar.gz -C site/software/gnuboot/
> +
> guix shell \
> --container \
> --network \
> --emulate-fhs \
> bash \
> coreutils \
> + findutils \
> grep \
> gzip \
> + sed \
> tar \
> -- \
> + ./check.sh --directory site && \
> ./check.sh --tarball website.tar.gz
> else
> -check: website.tar.gz
> - ./check.sh --tarball website.tar.gz
> +check: build website.tar.gz
> + rm -rf site/
> + mkdir -p site/software/gnuboot/
> + tar xf website.tar.gz -C site/software/gnuboot/
> + ./check.sh --directory site
> + ./check.sh --tarball website.tar.gz
> endif
>
> help:
> diff --git a/website-build/check.sh b/website-build/check.sh
> index 363dd43..c0fb90a 100755
> --- a/website-build/check.sh
> +++ b/website-build/check.sh
> @@ -23,16 +23,36 @@ usage()
> {
> progname="$1"
>
> - echo "Usage: ${progname} [options]"
> + echo "Usage: ${progname} <option [ARGUMENT]>"
> echo ""
> echo "Available options:"
> echo -e "\t-h, --help"
> echo -e "\t\tDisplay this help and exit."
> + echo -e "\t-d, --directory DIRECTORY"
> + echo -e "\t\tCheck DIRECTORY"
> echo -e "\t-t, --tarball TARBALL"
> echo -e "\t\tCheck TARBALL\n"
> }
>
> -test_pattern()
> +test_directory_pattern()
> +{
> + name="$1"
> + directory="$2"
> + pattern="$3"
> +
> + find "${directory}" -print0 | sed "s#^${directory}/##" | grep -q
> "${pattern}"
> +
> + result=$?
> +
> + if [ ${result} -eq 0 ] ; then
> + echo "[ OK ] ${name}"
> + else
> + echo "[ !! ] ${name} failed"
> + exit 1
> + fi
> +}
> +
> +test_tarball_pattern()
> {
> name="$1"
> tarball="$2"
> @@ -50,7 +70,7 @@ test_pattern()
> fi
> }
>
> -test_savannah_cvs_constraints()
> +test_tarball_savannah_cvs_constraints()
> {
> name="$1"
> tarball="$2"
> @@ -65,13 +85,30 @@ test_savannah_cvs_constraints()
> fi
> }
>
> +run_directory_tests()
> +{
> + directory="$1"
> +
> + directory_name="$(basename "${directory}")"
> +
> + test_directory_pattern "${directory_name}: index.html present test" \
> + "${directory}" \
> + 'software/gnuboot/index.html'
>
> -run_tests()
> + test_directory_pattern "${directory_name}: html test" \
> + "${directory}" \
> + 'software/gnuboot/web/.*\.html$'
> +}
> +
> +run_tarball_tests()
> {
> - test_pattern "html test" "${tarball}" '\.html$'
> - test_pattern "jpg test" "${tarball}" '\.jpg$'
> - test_savannah_cvs_constraints \
> - "Savannah CVS: Only /index.html in root directory" \
> + tarball="$1"
> +
> + filename="$(basename "${tarball}")"
> + test_tarball_pattern "${filename}: html test" "${tarball}" '\.html$'
> + test_tarball_pattern "${filename}: jpg test" "${tarball}" '\.jpg$'
> + test_tarball_savannah_cvs_constraints \
> + "${filename}: Savannah CVS: Only /index.html in root directory" \
> "${tarball}"
> }
>
> @@ -80,9 +117,12 @@ run_tests()
> if [ $# -eq 1 ] && [ "$1" = "-h" -o "$1" == "--help" ] ; then
> usage "check.sh"
> exit 0
> +elif [ $# -eq 2 ] && [ "$1" = "-d" -o "$1" = "--directory" ] ; then
> + directory="$(realpath "$2")"
> + run_directory_tests "${directory}"
> elif [ $# -eq 2 ] && [ "$1" = "-t" -o "$1" = "--tarball" ] ; then
> tarball="$(realpath "$2")"
> - run_tests "${tarball}"
> + run_tarball_tests "${tarball}"
> else
> usage "check.sh"
> exit ${EX_USAGE}
Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
signature.asc
Description: This is a digitally signed message part
- Re: [PATCH v1 10/18] website-build: targets: rename targets to use build, serve and publish., (continued)
- [PATCH v1 13/18] website-build: configure: make realpath and tar requirement work., Denis 'GNUtoo' Carikli, 2024/05/25
- [PATCH v1 14/18] website-build: configure: require awk., Denis 'GNUtoo' Carikli, 2024/05/25
- [PATCH v1 15/18] website-build: serve.sh: help: fix program name., Denis 'GNUtoo' Carikli, 2024/05/25
- [PATCH v1 16/18] website-build: check.sh: help: fix program name., Denis 'GNUtoo' Carikli, 2024/05/25
- [PATCH v1 18/18] website-build: check.sh: start adding tests for site/., Denis 'GNUtoo' Carikli, 2024/05/25
- Re: [PATCH v1 18/18] website-build: check.sh: start adding tests for site/.,
Adrien 'neox' Bourmault <=
- [PATCH v1 17/18] website-build: serve.sh: remove the need for random temporary directory., Denis 'GNUtoo' Carikli, 2024/05/25