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 249, Thu Apr 7 13:58:27 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,verbose)
52    if(verbose)cat("\n")    if(verbose)cat("\n")
53  }  }
54    
55    make.package.and.check <- function
56    ### Assemble some R code into a package and process it using R CMD
57    ### check, stopping with an error if the check resulted in any errors
58    ### or warnings.
59    (f, ##<< R code file name from which we will make a package
60     parsers=default.parsers,
61    ### Parsers to use to make the package documentation.
62     verbose=TRUE
63    ### print the check command line?
64     ){
65      pkgname <- sub(".[rR]$","",basename(f))
66      pkgdir <- file.path(tempdir(),pkgname)
67      if(file.exists(pkgdir))unlink(pkgdir,recursive=TRUE)
68      rdir <- file.path(pkgdir,"R")
69      dir.create(rdir,recursive=TRUE)
70      desc <- file.path(system.file(package="inlinedocs"),"silly","DESCRIPTION")
71      file.copy(desc,pkgdir)
72      file.copy(f,rdir)
73      print(pkgdir)
74      package.skeleton.dx(pkgdir,parsers)
75      cmd <- sprintf("%s CMD check %s",file.path(R.home("bin"), "R"),pkgdir)
76      if(verbose)cat(cmd,"\n")
77      checkLines <- system(cmd,intern=TRUE)
78      warnLines <- grep("WARNING",checkLines,value=TRUE)
79      if(length(warnLines)>0){
80        print(warnLines)
81        stop("WARNING encountered in package check!")
82      }
83    }
84    
85  save.test.result <- function  save.test.result <- function
86  ### For unit tests, this is an easy way of getting a text  ### For unit tests, this is an easy way of getting a text
87  ### 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.249

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