1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#!/bin/bash
set -e
. tests/lib-core
. tests/lib-restricts
mode=$1
test-begin- () {
whynots=''
}
restriction- () {
set +e
whynot=$(t-restriction-${r//,/ })
rc=$?
whynot="${whynot//
/ / }"
set -e
case "$rc.$whynot" in
0.) ;;
1.?*) whynots="$whynots${whynots:+; }$whynot" ;;
*) fail "restriction $r for $t gave $rc $whynot !"
esac
}
dependencies- () {
:
}
test-done- () {
case "$whynots" in
'') echo $t ;;
?*) echo >&2 "SKIP $t $whynots" ;;
esac
}
finish- () {
:
}
test-begin-gencontrol () {
restrictions=''
dependencies='dgit, dgit-infrastructure, devscripts, debhelper (>=8), fakeroot, build-essential, chiark-utils-bin, bc, faketime, liburi-perl'
}
gencontrol-add-things () {
local varname=$1; shift
local delim=$1; shift
local thing
eval '
for thing in "$@"; do
case " $'$varname$delim '" in
*" "$thing"'$delim' "*) continue ;;
esac
'$varname'+="${'$varname':+'$delim' }$thing"
done
'
}
restriction-gencontrol () {
case "$r" in
x-dgit-out-of-tree-only) return ;;
# Deliberately don't honour suite restrictions in formal autopkgtests.
# Test dependencies should handle that as needed.
x-dgit-skip-suite,*) return ;;
esac
gencontrol-add-things restrictions '' "$r"
}
gencontrol-add-deps () {
gencontrol-add-things dependencies , "$@"
}
dependencies-gencontrol () {
for dep in "$deps"; do
case "$dep" in
NO-DGIT) dependencies='chiark-utils-bin, faketime' ;;
NO-DEFAULT) dependencies='' ;;
GDR) gencontrol-add-deps \
git-debrebase git-buildpackage
;;
DEBORIG) gencontrol-add-deps \
devscripts libdpkg-perl \
libgit-wrapper-perl liblist-compare-perl \
libstring-shellquote-perl libtry-tiny-perl \
# NB git-deborig is not compatible with
# t-tstunt-parsechangelog
;;
DEBPUSH) gencontrol-add-deps \
git-debpush
;;
T2U) gencontrol-add-deps \
git-debpush autopkgtest python3-pygit2 netcat-openbsd
;;
*) gencontrol-add-deps "$dep" ;;
esac
done
}
test-done-gencontrol () {
stanza=$(
add_Depends="$dependencies" \
perl <debian/tests/control.in -wpe '
if (/^(\w+):/) {
my $h = $1;
s{$}{ $ENV{"add_$h"} // "" }e;
}
'
case "$restrictions" in
?*) echo "Restrictions: $restrictions" ;;
esac
)
key=$(printf "%s" "$stanza" | sha256sum)
key=${key%% *}
eval "
stanza_$key=\"\$stanza\"
tests_$key+=\" \${t#tests/tests/}\"
"
keys=" ${keys/ $key /}"
keys+=" $key "
}
finish-gencontrol () {
for key in $keys; do
eval "
stanza=\$stanza_$key
tests=\$tests_$key
"
printf "Tests:%s\n%s\n\n" "$tests" "$stanza"
done
}
test-begin-dep-packages () {
test-begin-gencontrol
test-begin-
}
test-done-dep-packages () {
test-begin-gencontrol
}
dependencies-dep-packages () {
dependencies-gencontrol
}
restriction-dep-packages () {
restriction-
}
test-done-dep-packages () {
if [ -z "$whynots" ]; then
all_dependencies+=" $dependencies"
else
echo >&2 "skipping $t: $whynot"
fi
}
finish-dep-packages () {
perl -e '
# include every dependency, but without version
$_ = $ARGV[0];
s{\([^()]*\)}{}g;
s{\,}{ }g;
$y{$_}=1 foreach split /\s+/;
printf "%s\n", join " ", sort keys %y or die $!;
' -- "$all_dependencies"
}
seddery () {
local seddery=$1
sed <$tf -n '
20q;
/^: t-enumerate-tests-end$/q;
'"$seddery"'
'
}
allsedderies () {
local tf=$1
for r in $(seddery 's/^t-restrict //p'); do
restriction-$mode
done
for deps in $(seddery 's/^t-dependencies //p'); do
dependencies-$mode
done
for import in $(seddery 's/^t-setup-import //p'); do
allsedderies tests/setup/$import
done
if egrep -q '^t-alt-test *$' <$tf; then
local leaf=${tf#tests/tests/}
allsedderies tests/tests/"${leaf#*-}"
fi
}
: ${TESTSCRIPTS=$(run-parts --list tests/tests)}
for t in $TESTSCRIPTS; do
test-begin-$mode
allsedderies $t
test-done-$mode
done
finish-$mode
|