/usr/share/octave-pkg-dev/check-pkg is in octave-autopkgtest 2.0.1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
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 | #!/bin/sh
# Set the octave executable and the octave options, when the
# corresponding variables are absent from the environment.
: ${octave:=octave-cli}
: ${octave_options:="--no-history --silent --no-init-file --no-window-system"}
[ -e PKG_ADD ] && mv PKG_ADD PKG_ADD.bak
echo Checking package...
unit_test_regex='^%!\(assert\|test\|error\|fail\|xtest\|warning\)'
# Extract tests from installed m files
tmp_script=$(tempfile)
tmp_results=$(tempfile)
cat >$tmp_script <<EOF
fid = fopen ("$tmp_results", "w");
disp ('echo Checking m files ...');
addpath (genpath (sprintf ('%s/debian', pwd ())));
[usr_pkg, sys_pkg] = pkg ('list');
for i = 1 : length (sys_pkg)
pkg ('load', sys_pkg {1, i}.name);
endfor
EOF
for f in $(find inst/ -name \*.m $excluded_files_expr | grep -v /private/) ; do
if grep -q "$unit_test_regex" $f ; then
stem=$(echo $f | sed 's:[^@]*/::;s/\.m$//')
cat >>$tmp_script <<EOF
disp ("[$stem]");
[npass, ntest, nxfail, nskip] = test ("$stem",
ifelse (strcmp ("$OCTPKG_TEST_OPT", ""),
"verbose", "$OCTPKG_TEST_OPT"));
printf ("%d test%s, %d passed, %d known failure%s, %d skipped\n",
ntest, ifelse (ntest > 1, "s", ""), npass, nxfail,
ifelse (nxfail > 1, "s", ""), nskip);
fprintf (fid, "%s %d %d %d %d\n", "$stem", ntest, npass, nxfail, nskip);
EOF
fi
done
# Extract tests from .cc files - these are not installed, but the
# compiled .oct files are.
# We search for the tests in the .cc files, but invoke the .oct files;
# this means we must add generate a loadpath starting at the current
# directory and source PKG_ADD files (they might add autoload()
# directives)
# We deactivate the warning about relative paths used for the PKG_ADD file.
cat >>$tmp_script <<EOF
disp ('echo Checking CC files ...');
addpath (genpath (pwd (), '.pc'));
[usr_pkg, sys_pkg] = pkg ('list');
for i = 1 : length (sys_pkg);
pkg ('load', sys_pkg {1, i}.name);
endfor
warning ('off', 'Octave:autoload-relative-file-name');
EOF
if [ -f PKG_ADD ] ; then
echo "source('PKG_ADD');" >> $tmp_script
fi
if [ -f PKG_ADD.bak ] ; then
echo "source('PKG_ADD.bak');" > $tmp_script
fi
if [ -d src ] ; then
for f in $(find src/ -name \*.cc $excluded_files_expr) ; do
if grep -q "$unit_test_regex" $f ; then
stem=${f%%.cc}
stem=${stem##*/}
cat >>$tmp_script <<EOF
disp ("[$stem]");
[npass, ntest, nxfail, nskip] = test ("$stem",
ifelse (strcmp ("$OCTPKG_TEST_OPT", ""),
"verbose", "$OCTPKG_TEST_OPT"));
printf ("%d test%s, %d passed, %d known failure%s, %d skipped\n",
ntest, ifelse (ntest > 1, "s", ""), npass, nxfail,
ifelse (nxfail > 1, "s", ""), nskip);
fprintf (fid, "%s %d %d %d %d\n", "$stem", ntest, npass, nxfail, nskip);
EOF
fi
done
echo "fclose (fid);" >>$tmp_script
fi
$OCTPKG_TEST_ENV $octave $octave_options $tmp_script
rm -f $tmp_script
if [ -f debian/check.m ] ; then
$OCTPKG_TEST_ENV $octave $octave_options --eval \
"addpath (genpath ([pwd(), '/debian'])); \
[usr_pkg, sys_pkg] = pkg ('list'); \
for i = 1 : length (sys_pkg); \
pkg ('load', sys_pkg {1, i}.name); \
endfor; \
source ('debian/check.m');"
fi
if [ -e PKG_ADD.bak ] ; then
mv PKG_ADD.bak PKG_ADD
fi
ntest=0
npass=0
nxfail=0
nskip=0
while read f1 f2 f3 f4 f5 ; do
ntest=$((ntest + f2))
npass=$((npass + f3))
nxfail=$((nxfail + f4))
nskip=$((nskip + f5))
done < $tmp_results
rm -f $tmp_results
echo "Summary: $ntest tests, $npass passed, $nxfail known failures, $nskip skipped"
if [ "$ntest" -gt $((npass + nxfail + nskip)) ] ; then
exit 1
fi
|