Bug 15045 - Add support for R CMD check --level and env var _R_CHECK_LEVEL_
Summary: Add support for R CMD check --level and env var _R_CHECK_LEVEL_
Status: ASSIGNED
Alias: None
Product: R
Classification: Unclassified
Component: Wishlist (show other bugs)
Version: R 2.15.1 patched
Hardware: Other Other
: P3 enhancement
Assignee: R-core
URL:
Depends on:
Blocks:
 
Reported: 2012-09-07 17:57 UTC by Greg Warnes
Modified: 2012-09-08 14:07 UTC (History)
1 user (show)

See Also:


Attachments
Patch created by svn diff against R-devel rev 60601 (11.06 KB, application/octet-stream)
2012-09-07 17:57 UTC, Greg Warnes
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Greg Warnes 2012-09-07 17:57:42 UTC
Created attachment 1372 [details]
Patch created by svn diff against R-devel rev 60601 

Discussions have been occurring on R-devel about a mechanism for packages to support controlling the depth of tests executed during 'R CMD check', particularly in order to properly support short execution times for 'R CMD check --as-cran'.

Attached is a patch against the current SVN version of R-devel (rev 60601)  that implements this functionality.    

Key features:

1) New environement variable _R_CHECK_LEVEL_ which can take values from {NONE, MINOR, CRAN, DEFAULT, MAJOR, FULL}

2) New R CMD CHECK flag --level={NONE, MINOR, CRAN, DEFAULT, MAJOR, FULL}, which sets the value of _R_CHECK_LEVEL_, overwriting any previous environment variable and defaulting to "DEFAULT".

3) R CMD CHECK flag --as-cran sets _R_CHECK_LEVEL_ to CRAN (overwriting any previous environment variable or --level setting)

4) A new function: tools::getCheckLevel() that returns an ordered factor with levels {NONE, MINOR, CRAN, DEFAULT, MAJOR, FULL}.

5) An associated man page, with the example:

	if(getCheckLevel() > "CRAN") {
	    cat("## Do time-intenstive test ##\n")
	} else {
	    cat("## Do brief test\n")
	}

6. Modifications to R-int.texi to document the new environment variable.

This patch does not include changes to R-ext or tools-Ex.Rout.save, but I would be glad to add these when appropriate.

I have compiled a local version of R-devel and have tested this patch in a number of ways, by adding the following files to gtools/test:

gtools/tests/test_getCheckLevel.R:
     ## Test that the getCheckLevel() function operates properly
     
     ## Display the values
     tools::getCheckLevel()
     
     ## Use it
     if(tools::getCheckLevel() > "CRAN") {
       cat("## Do time-intenstive test ##\n")
     } else {
       cat("## Do brief test\n")
     }

gtools/tests/test_getCheckLevel.Rout.save:
     R Under development (unstable) (2012-09-07 r60601) -- "Unsuffered Consequences"
     Copyright (C) 2012 The R Foundation for Statistical Computing
     ISBN 3-900051-07-0
     Platform: i386-apple-darwin10.8.0/i386 (32-bit)
     
     R is free software and comes with ABSOLUTELY NO WARRANTY.
     You are welcome to redistribute it under certain conditions.
     Type 'license()' or 'licence()' for distribution details.
     
       Natural language support but running in an English locale
     
     R is a collaborative project with many contributors.
     Type 'contributors()' for more information and
     'citation()' on how to cite R or R packages in publications.
     
     Type 'demo()' for some demos, 'help()' for on-line help, or
     'help.start()' for an HTML browser interface to help.
     Type 'q()' to quit R.
     
     > ## Test that the getCheckLevel() function operates properly
     > 
     > ## Display the values
     > tools::getCheckLevel()
     [1] DEFAULT
     Levels: NONE < MINOR < CRAN < DEFAULT < MAJOR < FULL
     > 
     > ## Use it
     > if(tools::getCheckLevel() > "CRAN") {
     +   cat("## Do time-intenstive test ##\n")
     + } else {
     +   cat("## Do brief test\n")
     + }
     ## Do time-intenstive test ##
     > 
     > proc.time()
        user  system elapsed 
       0.293   0.027   0.310 


Test runs included: 
1) Running 'R CMD check --help';
2) Running 'R CMD check <package>' without any additional arguments or environment variables 
3) Running 'R CMD check --level=<level> <package>' without any additional environment variables, for various valid values of '<level>'
4) Running 'R CMD check --level=<badstr> <package>' without any additional environment variables, for variaous invalid values of '<badstr>' incuding the empty string
5) Running 'R CMD check --as-cran <package>' without any additional arguments or environment variables 
6) Running 'R CMD check <package>' with the environment variable _R_CHECK_LEVEL_ set to various valid values
7) Running 'R CMD check <package>' with the environment variable _R_CHECK_LEVEL_ set to various valid values
8) Running 'R CMD check --level=<level> <package>' with the environment variable _R_CHECK_LEVEL_ set to various valid values
9) Running 'R CMD check --level=<level> <package>' with the environment variable _R_CHECK_LEVEL_ set to various valid values

The code appears to operate properly in each of these cases, resulting in a correct/valid value for getCheckLevel().

-Greg
Comment 1 Martin Maechler 2012-09-08 14:07:08 UTC
I'm going to check it myself, and then discuss within R-core how to proceed.