[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: autodep8 for R packages?



On 30 March 2016 at 23:16, Gordon Ball wrote:
| For the set of R packages I recently uploaded, I added trivial DEP-8
| tests* which did:
| 
|     R -e "if (! require('$pkg')) quit(status=1)"

require() is deprecated. Use

    requireNamespace("$pkg", quietly=TRUE)

which also returns a boolean.   Or simply

    library("$pkg")

which either dies, or proceeds in which case you can follow with q(status=1).
 
| Which I think is sufficient to trivially test whether a package has been
| properly installed with required dependencies and hence can be loaded by R.
| 
| Would it be useful to try and get a rule to do this automatically into
| autodep8 (suggested by Mattia who sponsored my original uploads), and
| hence provide a minimal autopkgtest for all R packages? (Are there any
| corner cases in which this wouldn't work?)

Not sure.
    Pro: Additional test.
    Con: Test is already done at package build time (ie R itself does this)
However, the ability to batch test _outside of package build_ may be useful.
But then see above -- requireNamespace("$pkg", quietly=TRUE)  already does that.

(Shameless plug:  Also see my littler package (now called r-cran-littler)
which makes command-line use of R a little saner.  R itself has Rscript too.)

Dirk

| I think autodep8 `detect` and `generate` scripts something like this
| would work (although I haven't tested them properly yet):
| 
| autodep8:support/r/detect
| #!/bin/sh
| grep-dctrl --quiet -F Source -r '^r-.*$' debian/control && \
| test -f DESCRIPTION
| 
| 
| autodep8:support/r/generate
| #!/bin/sh
| upstream_name=$(grep-dctrl -s Package -n . DESCRIPTION)
| if [ -z "$upstream_name" ]; then
|   exit 1
| fi
| 
| cat <<EOF
| Test-Command: R -e "if (! require('$upstream_name')) quit(status=1)"
| Depends: @
| Restrictions: allow-stderr
| EOF
| 
| 
| 
| (conveniently R DESCRIPTION files use the same format as debian/control
| so we can use grep-dctrl to extract the R package name)
| 
| 
| Worth developing further?
| 
| Gordon
| 
| 
| 
| 
| *Actually, these didn't work correctly because I forgot to add
| `Restrictions: allow-stderr` and the tests are marked as failed since R
| prints package loading messages to stderr, but this will be fixed in the
| next upload.
| 

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd@debian.org


Reply to: