11
2- # Copyright (C) 2012 - 2019 JJ Allaire, Dirk Eddelbuettel and Romain Francois
2+ # Copyright (C) 2012 - 2020 JJ Allaire, Dirk Eddelbuettel and Romain Francois
33#
44# This file is part of Rcpp.
55#
@@ -83,7 +83,7 @@ sourceCpp <- function(file = "",
8383
8484 # print output for verbose mode
8585 if (verbose )
86- .printVerboseOutput(context )
86+ .printVerboseOutput(context ) # #nocov
8787
8888 # variables used to hold completed state (passed to completed hook)
8989 succeeded <- FALSE
@@ -115,7 +115,7 @@ sourceCpp <- function(file = "",
115115 # on.exit handler calls hook and restores environment and working dir
116116 on.exit({
117117 if (! succeeded )
118- .showBuildFailureDiagnostics()
118+ .showBuildFailureDiagnostics() # #nocov
119119 .callBuildCompleteHook(succeeded , output )
120120 setwd(cwd )
121121 .restoreEnvironment(envRestore )
@@ -139,7 +139,7 @@ sourceCpp <- function(file = "",
139139 shQuote(context $ cppSourceFilename ), " " ,
140140 sep = " " )
141141 if (showOutput )
142- cat(cmd , " \n " )
142+ cat(cmd , " \n " ) # #nocov
143143
144144 # execute the build -- suppressWarnings b/c when showOutput = FALSE
145145 # we are going to explicitly check for an error and print the output
@@ -176,14 +176,14 @@ sourceCpp <- function(file = "",
176176 on.exit({
177177 setwd(cwd )
178178 })
179- if (verbose )
179+ if (verbose ) # #nocov start
180180 cat(" \n No rebuild required (use rebuild = TRUE to " ,
181181 " force a rebuild)\n\n " , sep = " " )
182182 }
183183
184184 # return immediately if this was a dry run
185185 if (dryRun )
186- return (invisible (NULL ))
186+ return (invisible (NULL )) # #nocov end
187187
188188 # load the module if we have exported symbols
189189 if (length(context $ exportedFunctions ) > 0 || length(context $ modules ) > 0 ) {
@@ -211,7 +211,7 @@ sourceCpp <- function(file = "",
211211
212212 # cleanup the cache dir if requested
213213 if (cleanupCacheDir )
214- cleanupSourceCppCache(cacheDir , context $ cppSourcePath , context $ buildDirectory )
214+ cleanupSourceCppCache(cacheDir , context $ cppSourcePath , context $ buildDirectory ) # #nocov
215215
216216 # return (invisibly) a list containing exported functions and modules
217217 invisible (list (functions = context $ exportedFunctions ,
@@ -295,13 +295,13 @@ cppFunction <- function(code,
295295 " \n --------------------------------------------------------\n\n " )
296296 cat(code )
297297 cat(" \n " )
298- } # #nocov end
298+ }
299299
300300 # source cpp into specified environment. if env is set to NULL
301301 # then create a new one (the caller can get a hold of the function
302302 # via the return value)
303303 if (is.null(env ))
304- env <- new.env()
304+ env <- new.env() # #nocov end
305305 exported <- sourceCpp(code = code ,
306306 env = env ,
307307 rebuild = rebuild ,
@@ -311,9 +311,9 @@ cppFunction <- function(code,
311311
312312 # verify that a single function was exported and return it
313313 if (length(exported $ functions ) == 0 )
314- stop(" No function definition found" )
314+ stop(" No function definition found" ) # #nocov
315315 else if (length(exported $ functions ) > 1 )
316- stop(" More than one function definition" )
316+ stop(" More than one function definition" ) # #nocov
317317 else {
318318 functionName <- exported $ functions [[1 ]]
319319 invisible (get(functionName , env ))
@@ -405,7 +405,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
405405 pkgdir <- normalizePath(pkgdir , winslash = " /" )
406406 descFile <- file.path(pkgdir ," DESCRIPTION" )
407407 if (! file.exists(descFile ))
408- stop(" pkgdir must refer to the directory containing an R package" )
408+ stop(" pkgdir must refer to the directory containing an R package" ) # #nocov
409409 pkgDesc <- read.dcf(descFile )[1 ,]
410410 pkgname = .readPkgDescField(pkgDesc , " Package" )
411411 depends <- c(.readPkgDescField(pkgDesc , " Depends" , character ()),
@@ -417,14 +417,14 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
417417 # check the NAMESPACE file to see if dynamic registration is enabled
418418 namespaceFile <- file.path(pkgdir , " NAMESPACE" )
419419 if (! file.exists(namespaceFile ))
420- stop(" pkgdir must refer to the directory containing an R package" )
420+ stop(" pkgdir must refer to the directory containing an R package" ) # #nocov
421421 pkgNamespace <- readLines(namespaceFile , warn = FALSE )
422422 registration <- any(grepl(" ^\\ s*useDynLib.*\\ .registration\\ s*=\\ s*TRUE.*$" , pkgNamespace ))
423423
424424 # determine source directory
425425 srcDir <- file.path(pkgdir , " src" )
426426 if (! file.exists(srcDir ))
427- return (FALSE )
427+ return (FALSE ) # #nocov
428428
429429 # create R directory if it doesn't already exist
430430 rDir <- file.path(pkgdir , " R" )
@@ -474,7 +474,7 @@ compileAttributes <- function(pkgdir = ".", verbose = getOption("verbose")) {
474474 pkgHeaderPath <- file.path(pkgdir , " src" , pkgHeader )
475475 pkgHeader <- pkgHeader [file.exists(pkgHeaderPath )]
476476 if (length(pkgHeader ) > 0 )
477- includes <- c(paste0(" #include \" " , pkgHeader ," \" " ), includes )
477+ includes <- c(paste0(" #include \" " , pkgHeader ," \" " ), includes ) # #nocov
478478
479479 # generate exports
480480 invisible (.Call(" compileAttributes" , PACKAGE = " Rcpp" ,
@@ -638,7 +638,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
638638# Split the depends field of a package description
639639.splitDepends <- function (x ) {
640640 if (! length(x ))
641- return (character ())
641+ return (character ()) # #nocov
642642 x <- unlist(strsplit(x , " ," ))
643643 x <- sub(" [[:space:]]+$" , " " , x )
644644 x <- unique(sub(" ^[[:space:]]*(.*)" , " \\ 1" , x ))
@@ -665,9 +665,9 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
665665
666666 plugin <- .plugins [[pluginName ]]
667667 if (is.null(plugin ))
668- stop(" Inline plugin '" , pluginName , " ' could not be found " ,
668+ stop(" Inline plugin '" , pluginName , " ' could not be found " , # #nocov start
669669 " within the Rcpp package. You should be " ,
670- " sure to call registerPlugin before using a plugin." )
670+ " sure to call registerPlugin before using a plugin." ) # #nocov end
671671
672672 return (plugin )
673673}
@@ -693,7 +693,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
693693 buildEnv [[name ]] <<- value
694694 }
695695 # if it's not identical then append
696- else if (! identical(buildEnv [[name ]], value )) {
696+ else if (! identical(buildEnv [[name ]], value )) { # #nocov
697697 buildEnv [[name ]] <<- paste(buildEnv [[name ]], value ) # #nocov
698698 }
699699 else {
@@ -875,7 +875,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
875875 # variables to reset
876876 setVars <- restore [! is.na(restore )]
877877 if (length(setVars ))
878- do.call(Sys.setenv , setVars )
878+ do.call(Sys.setenv , setVars ) # #nocov
879879
880880 # variables to remove
881881 removeVars <- names(restore [is.na(restore )])
@@ -934,7 +934,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
934934.getHooksList <- function (name ) {
935935 hooks <- getHook(name )
936936 if (! is.list(hooks ))
937- hooks <- list (hooks )
937+ hooks <- list (hooks ) # #nocov
938938 hooks
939939}
940940
@@ -948,7 +948,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
948948
949949 # This field can be NULL or empty -- in that case just return Rcpp.h
950950 if (is.null(linkingTo ) || ! nzchar(linkingTo ))
951- return (c(" #include <Rcpp.h>" ))
951+ return (c(" #include <Rcpp.h>" )) # #nocov
952952
953953 # Look for Rcpp inline plugins within the list or LinkedTo packages
954954 include.before <- character ()
@@ -1033,7 +1033,7 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
10331033.parseLinkingTo <- function (linkingTo ) {
10341034
10351035 if (is.null(linkingTo ))
1036- return (character ())
1036+ return (character ()) # #nocov
10371037
10381038 linkingTo <- strsplit(linkingTo , " \\ s*\\ ," )[[1 ]]
10391039 result <- gsub(" \\ s" , " " , linkingTo )
@@ -1217,15 +1217,15 @@ sourceCppFunction <- function(func, isVoid, dll, symbol) {
12171217 matches <- regexec(' ^\\ s+\\ {"([^"]+)",.*$' , code )
12181218 matches <- regmatches(code , matches )
12191219 matches <- Filter(x = matches , function (x ) {
1220- length(x ) > 0
1220+ length(x ) > 0 # #nocov start
12211221 })
12221222 for (match in matches ) {
12231223 routine <- match [[2 ]]
12241224 if (! routine %in% routines ) {
12251225 declaration <- grep(sprintf(" ^extern .* %s\\ (.*$" , routine ), code ,
12261226 value = TRUE )
12271227 declarations <- c(declarations , sub(" ^extern" , " RcppExport" , declaration ))
1228- call_entries <- c(call_entries , match [[1 ]])
1228+ call_entries <- c(call_entries , match [[1 ]]) # #nocov end
12291229 }
12301230 }
12311231 }
0 commit comments