Skip to content

Commit dfa8bbe

Browse files
committed
Re-enable catch tests on windows
Fixes #2102
1 parent 292d6c6 commit dfa8bbe

File tree

1 file changed

+20
-31
lines changed

1 file changed

+20
-31
lines changed

tests/test-catch.R

Lines changed: 20 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,43 @@
11
library(testthat)
22

33
local({
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 (!is_installed("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,6 @@ local({
5747
)
5848

5949
if (!catchEnabled) {
60-
6150
makevarsPath <- file.path(
6251
pkgPath,
6352
"src",
@@ -69,7 +58,6 @@ local({
6958
file = makevarsPath,
7059
sep = "\n"
7160
)
72-
7361
}
7462

7563
install.packages(pkgs = pkgPath, repos = NULL, type = "source")
@@ -78,6 +66,7 @@ local({
7866
pkgload::unload(pkgName)
7967
}
8068

81-
withr::with_envvar(c(R_TESTS = ''), perform_test("testthatclient1", TRUE))
82-
withr::with_envvar(c(R_TESTS = ''), perform_test("testthatclient2", FALSE))
69+
withr::local_envvar(R_TESTS = '')
70+
perform_test("testthatclient1", TRUE)
71+
perform_test("testthatclient2", FALSE)
8372
})

0 commit comments

Comments
 (0)