mmdebstrap/coverage.sh

114 lines
3.4 KiB
Bash
Raw Permalink Normal View History

2018-10-22 18:37:31 +00:00
#!/bin/sh
set -eu
if [ -e ./mmdebstrap ]; then
TMPFILE=$(mktemp)
perltidy < ./mmdebstrap > "$TMPFILE"
ret=0
diff -u ./mmdebstrap "$TMPFILE" || ret=$?
if [ "$ret" -ne 0 ]; then
echo "perltidy failed" >&2
rm "$TMPFILE"
exit 1
fi
rm "$TMPFILE"
2020-01-08 16:44:07 +00:00
2022-11-16 12:59:38 +00:00
if [ "$(sed -e '/^__END__$/,$d' ./mmdebstrap | wc --max-line-length)" -gt 79 ]; then
echo "exceeded maximum line length of 79 characters" >&2
exit 1
fi
2020-01-09 07:39:40 +00:00
perlcritic --severity 4 --verbose 8 ./mmdebstrap
fi
2020-01-18 22:13:10 +00:00
[ -e ./tarfilter ] && black --check ./tarfilter
[ -e ./coverage.py ] && black --check ./coverage.py
2022-11-16 12:59:38 +00:00
shellcheck --exclude=SC2016 coverage.sh make_mirror.sh run_null.sh run_qemu.sh gpgvnoexpkeysig hooks/*/*.sh
mirrordir="./shared/cache/debian"
2019-10-18 20:46:23 +00:00
if [ ! -e "$mirrordir" ]; then
echo "run ./make_mirror.sh before running $0" >&2
exit 1
fi
# we use -f because the file might not exist
rm -f shared/cover_db.img
: "${DEFAULT_DIST:=unstable}"
: "${HAVE_QEMU:=yes}"
: "${RUN_MA_SAME_TESTS:=yes}"
if [ "$HAVE_QEMU" = "yes" ]; then
# prepare image for cover_db
guestfish -N shared/cover_db.img=disk:64M -- mkfs vfat /dev/sda
if [ ! -e "./shared/cache/debian-$DEFAULT_DIST.qcow" ]; then
echo "./shared/cache/debian-$DEFAULT_DIST.qcow does not exist" >&2
exit 1
fi
fi
# check if all required debootstrap tarballs exist
notfound=0
for dist in oldstable stable testing unstable; do
for variant in minbase buildd -; do
if [ ! -e "shared/cache/debian-$dist-$variant.tar" ]; then
echo "shared/cache/debian-$dist-$variant.tar does not exist" >&2
notfound=1
fi
done
done
if [ "$notfound" -ne 0 ]; then
echo "not all required debootstrap tarballs are present" >&2
exit 1
fi
# choose the timestamp of the unstable Release file, so that we get
# reproducible results for the same mirror timestamp
SOURCE_DATE_EPOCH=$(date --date="$(grep-dctrl -s Date -n '' "$mirrordir/dists/$DEFAULT_DIST/Release")" +%s)
2018-10-22 18:37:31 +00:00
# for traditional sort order that uses native byte values
2018-12-27 13:16:23 +00:00
export LC_ALL=C.UTF-8
2018-10-22 18:37:31 +00:00
: "${HAVE_UNSHARE:=yes}"
: "${HAVE_BINFMT:=yes}"
# by default, use the mmdebstrap executable in the current directory together
# with perl Devel::Cover but allow to overwrite this
: "${CMD:=perl -MDevel::Cover=-silent,-nogcov ./mmdebstrap}"
mirror="http://127.0.0.1/debian"
2018-10-22 18:37:31 +00:00
export HAVE_QEMU HAVE_UNSHARE HAVE_BINFMT RUN_MA_SAME_TESTS DEFAULT_DIST SOURCE_DATE_EPOCH CMD mirror
./coverage.py
if [ -e shared/cover_db.img ]; then
# produce report inside the VM to make sure that the versions match or
# otherwise we might get:
# Can't read shared/cover_db/runs/1598213854.252.64287/cover.14 with Sereal: Sereal: Error: Bad Sereal header: Not a valid Sereal document. at offset 1 of input at srl_decoder.c line 600 at /usr/lib/x86_64-linux-gnu/perl5/5.30/Devel/Cover/DB/IO/Sereal.pm line 34, <$fh> chunk 1.
cat << END > shared/test.sh
cover -nogcov -report html_basic cover_db >&2
mkdir -p report
for f in common.js coverage.html cover.css css.js mmdebstrap--branch.html mmdebstrap--condition.html mmdebstrap.html mmdebstrap--subroutine.html standardista-table-sorting.js; do
cp -a cover_db/\$f report
done
cover -delete cover_db >&2
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
2022-11-16 12:59:38 +00:00
elif [ "$HAVE_UNSHARE" != "yes" ]; then
./run_null.sh SUDO
else
./run_null.sh
fi
echo
2022-11-16 12:59:38 +00:00
echo "open file://$(pwd)/shared/report/coverage.html in a browser"
echo
fi
2022-09-04 15:22:04 +00:00
rm shared/test.sh shared/tar1.txt shared/tar2.txt shared/pkglist.txt shared/doc-debian.tar.list shared/mmdebstrap shared/tarfilter shared/proxysolver