SCM

SCM Repository

[inlinedocs] Diff of /pkg/inlinedocs/R/test.R
ViewVC logotype

Diff of /pkg/inlinedocs/R/test.R

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 138, Tue Oct 19 22:51:59 2010 UTC revision 275, Fri May 27 11:55:21 2011 UTC
# Line 11  Line 11 
11   verbose=TRUE   verbose=TRUE
12  ### Show output?  ### Show output?
13   ){   ){
   result <- extract.docs.file(f)  
14    e <- new.env()    e <- new.env()
15    sys.source(f,e)    suppressWarnings(sys.source(f,e))
16    ## these are the items to check for, in no particular order    ## these are the items to check for, in no particular order
17    .result <- e$.result    .result <- e$.result
18      parsers <- e$.parsers
19      result <- extract.docs.file(f,parsers)
20    for(FUN in names(.result)){    for(FUN in names(.result)){
21      if(verbose)cat(FUN,"")      if(verbose)cat(FUN,"")
22      fun <- result[[FUN]]      fun <- result[[FUN]]
# Line 38  Line 39 
39        stop("extracted some unexpected docs!")        stop("extracted some unexpected docs!")
40      }      }
41    }    }
42      ## make sure there are no unexpected outer lists
43      not.expected <- names(result)[!names(result)%in%names(.result)]
44      if(length(not.expected)){
45        print(not.expected)
46        stop("extracted some unexpected documentation objects!")
47      }
48      ## finally make a package using this file and see if it passes
49      ## without warnings TDH 27 May 2011 added !interactive() since
50      ## recursive calling R CMD check seems to systematically
51      ## fail... ERROR: startup.Rs not found. This file is usually copied
52      ## to the check directory and read as a .Rprofile, as done in
53      ## tools:::.runPackageTests ... is this a bug in R? Anyway for now
54      ## let's just not run the R CMD check.
55      if(!is.null(e$.dontcheck) || !interactive())return()
56      make.package.and.check(f,parsers,verbose)
57    if(verbose)cat("\n")    if(verbose)cat("\n")
58  }  }
59    
60    make.package.and.check <- function
61    ### Assemble some R code into a package and process it using R CMD
62    ### check, stopping with an error if the check resulted in any errors
63    ### or warnings.
64    (f, ##<< R code file name from which we will make a package
65     parsers=default.parsers,
66    ### Parsers to use to make the package documentation.
67     verbose=TRUE
68    ### print the check command line?
69     ){
70      pkgname <- sub("[.][rR]$","",basename(f))
71      pkgdir <- file.path(tempdir(),pkgname)
72      if(file.exists(pkgdir))unlink(pkgdir,recursive=TRUE)
73      rdir <- file.path(pkgdir,"R")
74      if(verbose)print(rdir)
75      dir.create(rdir,recursive=TRUE)
76      desc <- system.file(file.path("silly","DESCRIPTION"),package="inlinedocs")
77      file.copy(desc,pkgdir)
78      file.copy(f,rdir)
79      package.skeleton.dx(pkgdir,parsers)
80      cmd <- sprintf("%s CMD check %s",file.path(R.home("bin"), "R"),pkgdir)
81      if(verbose)cat(cmd,"\n")
82      checkLines <- system(cmd,intern=TRUE)
83      warnLines <- grep("(WARNING|ERROR)",checkLines,value=TRUE)
84      if(length(warnLines)>0){
85        print(warnLines)
86        stop("ERROR/WARNING encountered in package check!")
87      }
88    }
89    
90  save.test.result <- function  save.test.result <- function
91  ### For unit tests, this is an easy way of getting a text  ### For unit tests, this is an easy way of getting a text
92  ### representation of the list result of extract.docs.file.  ### representation of the list result of extract.docs.file.

Legend:
Removed from v.138  
changed lines
  Added in v.275

root@r-forge.r-project.org
ViewVC Help
Powered by ViewVC 1.0.0  
Thanks to:
Vienna University of Economics and Business Powered By FusionForge