website-build: check.sh: start adding tests for site/.
Signed-off-by: Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org> Acked-by: Adrien 'neox' Bourmault <neox@gnu.org>
This commit is contained in:
parent
c2b4c87fda
commit
85a6444802
|
@ -49,20 +49,31 @@ build:
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if WANT_GUIX
|
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 \
|
guix shell \
|
||||||
--container \
|
--container \
|
||||||
--network \
|
--network \
|
||||||
--emulate-fhs \
|
--emulate-fhs \
|
||||||
bash \
|
bash \
|
||||||
coreutils \
|
coreutils \
|
||||||
|
findutils \
|
||||||
grep \
|
grep \
|
||||||
gzip \
|
gzip \
|
||||||
|
sed \
|
||||||
tar \
|
tar \
|
||||||
-- \
|
-- \
|
||||||
|
./check.sh --directory site && \
|
||||||
./check.sh --tarball website.tar.gz
|
./check.sh --tarball website.tar.gz
|
||||||
else
|
else
|
||||||
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/
|
||||||
|
./check.sh --directory site
|
||||||
./check.sh --tarball website.tar.gz
|
./check.sh --tarball website.tar.gz
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,36 @@ usage()
|
||||||
{
|
{
|
||||||
progname="$1"
|
progname="$1"
|
||||||
|
|
||||||
echo "Usage: ${progname} [options]"
|
echo "Usage: ${progname} <option [ARGUMENT]>"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Available options:"
|
echo "Available options:"
|
||||||
echo -e "\t-h, --help"
|
echo -e "\t-h, --help"
|
||||||
echo -e "\t\tDisplay this help and exit."
|
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-t, --tarball TARBALL"
|
||||||
echo -e "\t\tCheck TARBALL\n"
|
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"
|
name="$1"
|
||||||
tarball="$2"
|
tarball="$2"
|
||||||
|
@ -50,7 +70,7 @@ test_pattern()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
test_savannah_cvs_constraints()
|
test_tarball_savannah_cvs_constraints()
|
||||||
{
|
{
|
||||||
name="$1"
|
name="$1"
|
||||||
tarball="$2"
|
tarball="$2"
|
||||||
|
@ -65,13 +85,30 @@ test_savannah_cvs_constraints()
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
run_directory_tests()
|
||||||
run_tests()
|
|
||||||
{
|
{
|
||||||
test_pattern "html test" "${tarball}" '\.html$'
|
directory="$1"
|
||||||
test_pattern "jpg test" "${tarball}" '\.jpg$'
|
|
||||||
test_savannah_cvs_constraints \
|
directory_name="$(basename "${directory}")"
|
||||||
"Savannah CVS: Only /index.html in root directory" \
|
|
||||||
|
test_directory_pattern "${directory_name}: index.html present test" \
|
||||||
|
"${directory}" \
|
||||||
|
'software/gnuboot/index.html'
|
||||||
|
|
||||||
|
test_directory_pattern "${directory_name}: html test" \
|
||||||
|
"${directory}" \
|
||||||
|
'software/gnuboot/web/.*\.html$'
|
||||||
|
}
|
||||||
|
|
||||||
|
run_tarball_tests()
|
||||||
|
{
|
||||||
|
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}"
|
"${tarball}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,9 +117,12 @@ run_tests()
|
||||||
if [ $# -eq 1 ] && [ "$1" = "-h" -o "$1" == "--help" ] ; then
|
if [ $# -eq 1 ] && [ "$1" = "-h" -o "$1" == "--help" ] ; then
|
||||||
usage "check.sh"
|
usage "check.sh"
|
||||||
exit 0
|
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
|
elif [ $# -eq 2 ] && [ "$1" = "-t" -o "$1" = "--tarball" ] ; then
|
||||||
tarball="$(realpath "$2")"
|
tarball="$(realpath "$2")"
|
||||||
run_tests "${tarball}"
|
run_tarball_tests "${tarball}"
|
||||||
else
|
else
|
||||||
usage "check.sh"
|
usage "check.sh"
|
||||||
exit ${EX_USAGE}
|
exit ${EX_USAGE}
|
||||||
|
|
Loading…
Reference in New Issue