File: pkg-r-autopkgtest

package info (click to toggle)
dh-r 20230121
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 220 kB
  • sloc: perl: 1,938; sh: 412; makefile: 21
file content (45 lines) | stat: -rwxr-xr-x 1,079 bytes parent folder | download | duplicates (2)
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
#!/bin/sh -e

export LC_ALL=C.UTF-8

# R DESCRIPTION files use the debian control file format
# (see R package manual 1.1.1)
pkgname=$(grep-dctrl -s Package -n '' DESCRIPTION)
bioc=$(grep-dctrl -s biocViews -n '' DESCRIPTION)

# Try to load package
echo "Test: Try to load the R library ${pkgname}"
R --no-save -e "library('${pkgname}')"

##########
# Test pkg-r-autopkgtest on Bioconductor packages only for now
if [ "$bioc" = "" ] ; then
  exit 0
fi
##########

# Create temp environment for testing
if [ "$AUTOPKGTEST_TMP" = "" ] ; then
  AUTOPKGTEST_TMP=`mktemp -d /tmp/${pkgname}-test.XXXXXX`
  trap "rm -rf $AUTOPKGTEST_TMP" 0 INT QUIT ABRT PIPE TERM
fi

cp -a * $AUTOPKGTEST_TMP
cd $AUTOPKGTEST_TMP

if [ -d debian/tests ] ; then
  if [ -e debian/tests/autopkgtest-pkg-r.hook ] ; then
    . debian/tests/autopkgtest-pkg-r.hook
  fi
fi

NBTEST=`find tests -type f -name "*.R" | wc -l`
if [ "$NBTEST" -gt "0" ] ; then
  echo "Test: Run tests for ${pkgname}"
  cd tests
  for testfile in *.R; do
    echo "Start: ${testfile}"
    R --no-save < ${testfile}
  done
  exit 0
fi