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 239, Mon Mar 28 16:07:28 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
50      if(!is.null(e$.dontcheck))return()
51      make.package.and.check(f,parsers)
52    if(verbose)cat("\n")    if(verbose)cat("\n")
53  }  }
54    
55    ### Make a package by processing f with a standard DESCRIPTION, and
56    ### stop if there are errors or warnings.
57    make.package.and.check <- function(f,parsers=default.parsers){
58      pkgname <- sub(".[rR]$","",basename(f))
59      pkgdir <- file.path(tempdir(),pkgname)
60      if(file.exists(pkgdir))unlink(pkgdir,recursive=TRUE)
61      rdir <- file.path(pkgdir,"R")
62      dir.create(rdir,recursive=TRUE)
63      desc <- file.path(system.file(package="inlinedocs"),"silly","DESCRIPTION")
64      file.copy(desc,pkgdir)
65      file.copy(f,rdir)
66      print(pkgdir)
67      package.skeleton.dx(pkgdir,parsers)
68      cmd <- sprintf("%s CMD check %s",file.path(R.home("bin"), "R"),pkgdir)
69      if(verbose)cat(cmd,"\n")
70      checkLines <- system(cmd,intern=TRUE)
71      warnLines <- grep("WARNING",checkLines,value=TRUE)
72      if(length(warnLines)>0){
73        print(warnLines)
74        stop("WARNING encountered in package check!")
75      }
76    }
77    
78  save.test.result <- function  save.test.result <- function
79  ### For unit tests, this is an easy way of getting a text  ### For unit tests, this is an easy way of getting a text
80  ### 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.239

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