when re-execing itself, keep Devel::Cover options

This commit is contained in:
Johannes 'josch' Schauer 2020-01-08 15:33:49 +01:00
parent f2ad2976ef
commit 4fed488c35
Signed by untrusted user: josch
GPG key ID: F2CBA5C78FBD83E1
2 changed files with 18 additions and 31 deletions

View file

@ -49,7 +49,7 @@ if [ ! -e shared/mmdebstrap ] || [ mmdebstrap -nt shared/mmdebstrap ]; then
fi fi
starttime= starttime=
total=123 total=115
skipped=0 skipped=0
runtests=0 runtests=0
i=1 i=1
@ -1851,33 +1851,6 @@ END
./run_null.sh ./run_null.sh
runtests=$((runtests+1)) runtests=$((runtests+1))
fi fi
# Devel::Cover doesn't survive mmdebstrap re-exec-ing itself
# with fakechroot, thus, we do an additional run where we
# explicitly run mmdebstrap with fakechroot from the start
if [ "$mode" = "fakechroot" ]; then
print_header "mode=$mode,variant=$variant: create tarball (ver 2)"
cat << END > shared/test.sh
#!/bin/sh
set -eu
export LC_ALL=C.UTF-8
[ "\$(id -u)" -eq 0 ] && ! id -u user > /dev/null 2>&1 && adduser --gecos user --disabled-password user
prefix=
[ "\$(id -u)" -eq 0 ] && prefix="runuser -u user --"
\$prefix fakechroot fakeroot $CMD --mode=$mode --variant=$variant $DEFAULT_DIST /tmp/debian-chroot.tar $mirror
{ tar -tf /tmp/debian-chroot.tar;
printf "./etc/ld.so.cache\n./var/cache/ldconfig/\n";
[ "$variant" != "essential" ] && printf "./etc/.pwd.lock\n";
} | sort | diff -u "./$variant.txt" -
rm /tmp/debian-chroot.tar
END
if [ "$HAVE_QEMU" = "yes" ]; then
./run_qemu.sh
runtests=$((runtests+1))
else
./run_null.sh
runtests=$((runtests+1))
fi
fi
done done
# some variants are equal and some are strict superset of the last # some variants are equal and some are strict superset of the last
# special case of the buildd variant: nothing is a superset of it # special case of the buildd variant: nothing is a superset of it

View file

@ -84,6 +84,8 @@ my @devfiles = (
# 3 -> debug output # 3 -> debug output
my $verbosity_level = 1; my $verbosity_level = 1;
my $is_covering = !!(eval 'Devel::Cover::get_coverage()');
sub debug { sub debug {
if ($verbosity_level < 3) { if ($verbosity_level < 3) {
return; return;
@ -977,7 +979,11 @@ sub run_hooks($$) {
# we execute ourselves under sh to avoid having to # we execute ourselves under sh to avoid having to
# implement a clever parser of the quoting used in $script # implement a clever parser of the quoting used in $script
# for the filenames # for the filenames
exec 'sh', '-c', "$PROGRAM_NAME --hook-helper \"\$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" $script", my $prefix = "";
if($is_covering) {
$prefix = "$EXECUTABLE_NAME -MDevel::Cover=-silent,-nogcov ";
}
exec 'sh', '-c', "$prefix$PROGRAM_NAME --hook-helper \"\$1\" \"\$2\" \"\$3\" \"\$4\" \"\$5\" $script",
'exec', $options->{root}, $options->{mode}, $name, (defined $options->{qemu} ? "qemu-$options->{qemu}" : 'env', $verbosity_level); 'exec', $options->{root}, $options->{mode}, $name, (defined $options->{qemu} ? "qemu-$options->{qemu}" : 'env', $verbosity_level);
} }
waitpid($pid, 0); waitpid($pid, 0);
@ -2299,7 +2305,11 @@ sub main() {
} elsif (system('fakechroot --version>/dev/null') == 0) { } elsif (system('fakechroot --version>/dev/null') == 0) {
# the next fallback is fakechroot # the next fallback is fakechroot
# exec ourselves again but within fakechroot # exec ourselves again but within fakechroot
exec 'fakechroot', 'fakeroot', $PROGRAM_NAME, @ARGVORIG; my @prefix = ();
if($is_covering) {
@prefix = ($EXECUTABLE_NAME, '-MDevel::Cover=-silent,-nogcov');
}
exec 'fakechroot', 'fakeroot', @prefix, $PROGRAM_NAME, @ARGVORIG;
} elsif (system('proot --version>/dev/null') == 0) { } elsif (system('proot --version>/dev/null') == 0) {
# and lastly, proot # and lastly, proot
$options->{mode} = 'proot'; $options->{mode} = 'proot';
@ -2322,7 +2332,11 @@ sub main() {
error "need working fakechroot binary"; error "need working fakechroot binary";
} else { } else {
# exec ourselves again but within fakechroot # exec ourselves again but within fakechroot
exec 'fakechroot', 'fakeroot', $PROGRAM_NAME, @ARGVORIG; my @prefix = ();
if($is_covering) {
@prefix = ($EXECUTABLE_NAME, '-MDevel::Cover=-silent,-nogcov');
}
exec 'fakechroot', 'fakeroot', @prefix, $PROGRAM_NAME, @ARGVORIG;
} }
} elsif ($options->{mode} eq 'unshare') { } elsif ($options->{mode} eq 'unshare') {
if (!test_unshare(1)) { if (!test_unshare(1)) {