11library(testthat )
22
33local({
4-
5- # Disable test on Windows, pending devtools
6- # compatibility with new toolchain
7- isWindows <- Sys.info()[[" sysname" ]] == " Windows"
8- if (isWindows )
9- return ()
10-
11- # Disable tests on Solaris, because we don't use Catch there.
12- isSolaris <- Sys.info()[[" sysname" ]] == " SunOS"
13- if (isSolaris )
14- return ()
15-
16- if (! requireNamespace(" usethis" , quietly = TRUE ))
4+ if (! requireNamespace(" usethis" , quietly = TRUE )) {
175 return ()
18-
19- # devel <- try(pkgbuild::has_compiler(), silent = TRUE)
20- # if (!isTRUE(devel))
21- # return()
6+ }
227
238 quietly <- function (expr ) {
249 suppressMessages(capture_output(result <- expr ))
2510 result
2611 }
2712
2813 perform_test <- function (pkgName , catchEnabled ) {
29-
3014 owd <- setwd(tempdir())
3115 on.exit(setwd(owd ), add = TRUE )
3216
3317 pkgPath <- file.path(tempdir(), pkgName )
3418 libPath <- file.path(tempdir(), " rlib" )
35- if (! utils :: file_test(" -d" , libPath ))
19+ if (! utils :: file_test(" -d" , libPath )) {
3620 dir.create(libPath )
21+ }
3722 .libPaths(c(libPath , .libPaths()))
3823
39- on.exit({
40- unlink(pkgPath , recursive = TRUE )
41- unlink(libPath , recursive = TRUE )
42- }, add = TRUE )
24+ on.exit(
25+ {
26+ unlink(pkgPath , recursive = TRUE )
27+ unlink(libPath , recursive = TRUE )
28+ },
29+ add = TRUE
30+ )
4331
4432 quietly(usethis :: create_package(pkgPath , open = FALSE ))
4533 quietly(testthat :: use_catch(pkgPath ))
4634
47- cat(" LinkingTo: testthat" ,
48- file = file.path(pkgPath , " DESCRIPTION" ),
49- append = TRUE ,
50- sep = " \n " )
35+ cat(
36+ " LinkingTo: testthat" ,
37+ file = file.path(pkgPath , " DESCRIPTION" ),
38+ append = TRUE ,
39+ sep = " \n "
40+ )
5141
5242 cat(
5343 sprintf(" useDynLib(%s, .registration=TRUE)" , pkgName ),
@@ -57,7 +47,7 @@ local({
5747 )
5848
5949 if (! catchEnabled ) {
60-
50+ isWindows <- Sys.info()[[ " sysname " ]] == " Windows "
6151 makevarsPath <- file.path(
6252 pkgPath ,
6353 " src" ,
@@ -69,7 +59,6 @@ local({
6959 file = makevarsPath ,
7060 sep = " \n "
7161 )
72-
7362 }
7463
7564 install.packages(pkgs = pkgPath , repos = NULL , type = " source" )
@@ -78,6 +67,7 @@ local({
7867 pkgload :: unload(pkgName )
7968 }
8069
81- withr :: with_envvar(c(R_TESTS = ' ' ), perform_test(" testthatclient1" , TRUE ))
82- withr :: with_envvar(c(R_TESTS = ' ' ), perform_test(" testthatclient2" , FALSE ))
70+ withr :: local_envvar(R_TESTS = ' ' )
71+ perform_test(" testthatclient1" , TRUE )
72+ perform_test(" testthatclient2" , FALSE )
8373})
0 commit comments