-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcovrpage_checks.R
57 lines (39 loc) · 1.15 KB
/
covrpage_checks.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
check_for_tests <- function(testdir) {
res <- TRUE
on.exit(return(invisible(res)),add = TRUE)
if (!dir.exists(file.path(testdir, "testthat"))) {
res <- FALSE
stop(sprintf("testthat subdirectory does not exists in: '%s'", testdir))
}
if (length(list.files(file.path(testdir, "testthat"))) == 0) {
res <- FALSE
stop(sprintf("tests/testthat subdirectory does contain any test files in: '%s'", testdir))
}
}
#' @importFrom utils installed.packages
check_for_pkgs <- function(pkg) {
ret <- compare_pkgs(pkg)
on.exit(invisible(ret$Package),add = TRUE)
if ( nrow(ret) > 0 ) {
ret_str <- sprintf('%s: Required: %s Installed: %s',
ret$Package,
ret$Desc_Version,
ret$Installed_Version)
stop(
sprintf("The following packages must be installed/updated:\n%s",
paste0(ret_str, collapse = "\n"))
)
}
}
create_viewer <- function() {
viewer <- getOption("viewer")
if (!is.null(viewer)) {
viewerFunc <- function(url) {
viewer(url)
}
}
else {
viewerFunc <- utils::browseURL
}
return(viewerFunc)
}