no-segfault.Rin 5.61 KB
Newer Older
1 2 3 4 5 6
###-*- R -*-
###--- This "foo.Rin" script is only used to create the real script "foo.R" :

###--- We need to use such a long "real script" instead of a for loop,
###--- because "error --> jump_to_toplevel", i.e., outside any loop.

7 8
core.pkgs <- local({x <- installed.packages(.Library)
    unname(x[x[,"Priority"] %in% "base", "Package"])})
9
core.pkgs <-
10
    core.pkgs[- match(c("methods", "parallel", "tcltk", "stats4"), core.pkgs, 0)]
11
## move methods to the end because it has side effects (overrides primitives)
12 13 14
## stats4 requires methods
core.pkgs <- c(core.pkgs, "methods", "stats4")

15 16 17
stop.list <- vector("list", length(core.pkgs))
names(stop.list) <- core.pkgs

18
## -- Stop List for base/graphics/utils:
19
edit.int <- c("fix", "edit", "edit.data.frame", "edit.matrix",
20
              "edit.default", "vi", "file.edit",
21
              "emacs", "pico", "xemacs", "xedit", "RSiteSearch", "help.request")
22

23 24
## warning: readLines will work, but read all the rest of the script
## warning: trace will load methods.
25
## warning: rm and remove zap c0, l0, m0, df0
26
## warning: parent.env(NULL) <- NULL creates a loop
27
## warning: browseVignettes launches many browser processes.
28
## news, readNEWS, rtags are slow, and R-only code.
29
misc.int <- c("browser", "browseVignettes", "bug.report", "checkCRAN",
30
              "getCRANmirrors", "lazyLoad", "menu", "repeat",
31
              "readLines", "package.skeleton", "trace", "recover",
32 33 34
              "rm", "remove", "parent.env<-",
              "builtins", "data", "help", "news", "rtags", "vignette",
              "installed.packages")
35 36
inet.list <- c(apropos("download\\."),
               apropos("^url\\."), apropos("\\.url"),
37
               apropos("packageStatus"),
38
               paste(c("CRAN", "install", "update", "old"), "packages", sep="."))
39 40 41
socket.fun <- apropos("socket")
## "Interactive" ones:
dev.int <- c("X11", "x11", "pdf", "postscript",
42
             "xfig", "jpeg", "png", "pictex", "quartz",
43 44 45
             "svg", "tiff", "cairo_pdf", "cairo_ps",
             "getGraphicsEvent")
misc.2 <- c("asS4", "help.start", "browseEnv", "make.packages.html",
46 47
            "gctorture", "q", "quit", "restart", "try",
            "read.fwf", "source",## << MM thinks "FIXME"
48
            "data.entry", "dataentry", "de", apropos("^de\\."),
49
            "chooseCRANmirror", "setRepositories", "select.list", "View")
50 51 52
if(.Platform$OS.type == "windows") {
    dev.int <- c(dev.int, "bmp", "windows", "win.graph", "win.print",
                "win.metafile")
53
    misc.2 <- c(misc.2, "file.choose", "choose.files", "choose.dir",
54 55
    		"setWindowTitle", "loadRconsole",
                "arrangeWindows", "getWindowsHandles")
56 57
}

58 59 60 61
stop.list[["base"]] <-
    if(nchar(Sys.getenv("R_TESTLOTS"))) {## SEVERE TESTING, try almost ALL
	c(edit.int, misc.int)
    } else {
62
	c(inet.list, socket.fun, edit.int, misc.int, misc.2)
63
    }
64 65 66 67 68

## S4 group generics should not be called directly
## and doing so sometimes leads to infinite recursion
s4.group.generics <- c("Arith", "Compare", "Ops", "Logic", "Math", "Math2", "Summary", "Complex")

69
## warning: browseAll will tend to read all the script and/or loop forever
70
stop.list[["methods"]] <- c("browseAll", "recover", s4.group.generics)
71 72 73
stop.list[["tools"]] <- c("write_PACKAGES", # problems with Packages/PACKAGES
                          "testInstalledBasic",
                          "testInstalledPackages", # runs whole suite
74 75
                          "readNEWS",              # slow, pure R code
                          "findHTMLlinks", "pskill",
76
                          "texi2dvi", "texi2pdf",  # hang on Windows
77 78 79 80 81 82
                          "getVignetteInfo",       # very slow on large installation
                          "CRAN_package_db",       # slow, pure R code
                          "CRAN_check_results",
                          "CRAN_check_details",
                          "CRAN_memtest_notes",
                          "summarize_CRAN_check_status"
83
                          )
84
stop.list[["grDevices"]] <- dev.int
85
stop.list[["utils"]] <- c("Rprof", "aspell", # hangs on Windows
86
                          "winProgressBar",
87
                          inet.list, socket.fun, edit.int, misc.int, misc.2)
88 89 90

sink("no-segfault.R")

91 92 93
if(.Platform$OS.type == "unix") cat('options(pager = "cat")\n')
if(.Platform$OS.type == "windows") cat('options(pager = "console")\n')
cat('options(error=expression(NULL))',
94 95
    "# don't stop on error in batch\n##~~~~~~~~~~~~~~\n")

96
cat(".proctime00 <- proc.time()\n")
97 98 99 100

for (pkg in core.pkgs) {
  cat("### Package ", pkg, "\n",
      "###         ", rep("~",nchar(pkg)), "\n", collapse="", sep="")
101 102 103 104
  pkgname <- paste("package", pkg, sep=":")
  this.pos <- match(paste("package", pkg, sep=":"), search())
  lib.not.loaded <- is.na(this.pos)
  if(lib.not.loaded) {
105
      library(pkg, character = TRUE, warn.conflicts = FALSE)
106
      cat("library(", pkg, ")\n")
107
  }
108
  this.pos <- match(paste("package", pkg, sep=":"), search())
109

110
  for(nm in ls(pkgname)) { # <==>  no '.<name>' functions are tested here
111
      if(!(nm %in% stop.list[[pkg]]) &&
112
	 is.function(f <- get(nm, pos = pkgname))) {
113
	  cat("\n## ", nm, " :\n")
114 115 116 117 118 119

	  cat("c0 <- character(0)\n",
	      "l0 <- logical(0)\n",
	      "m0 <- matrix(1,0,0)\n",
	      "df0 <- as.data.frame(c0)\n", sep="")

120
	  cat("f <- get(\"",nm,"\", pos = '", pkgname, "')\n", sep="")
121 122 123 124 125 126 127
	  cat("f()\nf(NULL)\nf(,NULL)\nf(NULL,NULL)\n",
	      "f(list())\nf(l0)\nf(c0)\nf(m0)\nf(df0)\nf(FALSE)\n",
	      "f(list(),list())\nf(l0,l0)\nf(c0,c0)\n",
              "f(df0,df0)\nf(FALSE,FALSE)\n",
	      sep="")
      }
  }
128
  if(lib.not.loaded) {
129
      detach(pos=this.pos)
130
      cat("detach(pos=", this.pos, ")\n", sep="")
131 132 133 134 135 136
  }

  cat("\n##__________\n\n")
}

cat("proc.time() - .proctime00\n")