-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
violation of writing to package directory during tests
- Loading branch information
Showing
8 changed files
with
72 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
Package: psqn | ||
Type: Package | ||
Title: Partially Separable Quasi-Newton | ||
Version: 0.2.0 | ||
Version: 0.2.1 | ||
Authors@R: c(person("Benjamin", "Christoffersen", | ||
email = "[email protected]", | ||
role = c("cre", "aut"), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,38 @@ | ||
# skips test on macOS | ||
skip_on_macOS <- function() | ||
skip_if(Sys.info()["sysname"] == "Darwin") | ||
|
||
# the temporary directory we will use. This must be deleted! | ||
.temp_dir_to_use <- file.path(tempdir(), "tmp-psqn-cpp-dir") | ||
if(!dir.exists(.temp_dir_to_use)) | ||
dir.create(.temp_dir_to_use) | ||
|
||
# compiles a C++ file from the inst directory and returns the needed information | ||
# to delete all associated files and reset the working directory | ||
compile_cpp_file <- function(f, new_name = f, do_compile = TRUE){ | ||
old_wd <- getwd() | ||
# create the directory we will use | ||
success <- FALSE | ||
new_wd <- .temp_dir_to_use | ||
on.exit({ | ||
if(!success) | ||
setwd(old_wd) | ||
}, add = TRUE) | ||
# copy the file | ||
file.copy(system.file(f, package = "psqn"), | ||
file.path(new_wd, new_name)) | ||
# we have to copy all the headers | ||
file.copy( | ||
list.files(system.file("include", package = "psqn"), full.names = TRUE), | ||
new_wd) | ||
# set the working directory to the directory with all the files | ||
eval(bquote(setwd(.(new_wd)))) | ||
if(do_compile) | ||
Rcpp::sourceCpp(new_name) | ||
success <- TRUE | ||
list(old_wd = old_wd, new_wd = new_wd) | ||
} | ||
|
||
# resets everything following a call to compile_cpp_file | ||
reset_compile_cpp_file <- function(reset_info) | ||
setwd(reset_info$old_wd) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# remove the temporary directory | ||
gc() | ||
unlink(.temp_dir_to_use, recursive = TRUE) |