Commit | Line | Data |
---|---|---|
672594cf | 1 | # Setup a file structure under R_HOME_USER/pkgdev/ to run later tests |
53231452 | 2 | # @param reset Logical, TRUE to wipe everything under R_HOME_USER/pkgdev folder |
156f8ca6 BA |
3 | .pkgdev.setup = function(reset=FALSE) { |
4 | ||
5 | # environment variable R_HOME_USER must be set: everything starts here | |
6 | if (Sys.getenv("R_HOME_USER") == "") { | |
7 | cat("*** WARNING: for pkgdev to work properly, you need to specify\n") | |
8 | cat("*** an environment variable R_HOME_USER in a .Renviron file.\n") | |
9 | cat("*** Standard choice is /home/userName/.R under UNIX systems,\n") | |
672594cf | 10 | cat("*** or maybe C:/Users/userName/Documents/R under Windows\n") |
156f8ca6 BA |
11 | stop("Please specify R_HOME_USER before using pkgdev") |
12 | } | |
13 | ||
14 | # create convenient folders and files, if not already existing | |
15 | pkdev_path = file.path(Sys.getenv("R_HOME_USER"), "pkgdev") | |
16 | ||
17 | # clean up: wipe possibly existing pkgdev/ contents | |
18 | if (reset) { | |
19 | unlink(pkdev_path, recursive=TRUE) | |
20 | unlink(pkdev_path, recursive=TRUE) #bug? | |
21 | } | |
22 | ||
23 | # copy file structure only if directory is absent | |
24 | if (file.exists(pkdev_path)) return (NULL) | |
25 | ||
26 | # create testing file structure under pkgdev/ | |
27 | dir.create(pkdev_path) | |
28 | dir.create( file.path(pkdev_path,"R") ) | |
29 | dir.create( file.path(pkdev_path,"R","tests") ) | |
30 | writeLines(RunitTestsMethods, file.path(pkdev_path,"R","tests","unitTestsMethods.R")) | |
31 | dir.create( file.path(pkdev_path,"src") ) | |
32 | dir.create( file.path(pkdev_path,"src","tests") ) | |
33 | writeLines(CunitTestsMacros, file.path(pkdev_path,"src","tests","unitTestsMacros.c")) | |
34 | dir.create( file.path(pkdev_path,"pkgs") ) | |
35 | } |