| 1 |
|
| 2 |
skip_if_no_github_auth <- function() { |
| 3 |
token <- renv_bootstrap_github_token() |
| 4 |
skip_if(empty(token), "GITHUB_PAT is not set") |
| 5 |
} |
| 6 |
|
| 7 |
skip_if_no_python <- function() { |
| 8 |
has_python <- Sys.which("python3") != "" || Sys.which("python") != "" |
| 9 |
skip_if_not(has_python, "python is not installed") |
| 10 |
} |
| 11 |
|
| 12 |
sys_python <- function() { |
| 13 |
|
| 14 |
for (python in c("python3", "python")) { |
| 15 |
python <- Sys.which(python) |
| 16 |
if (nzchar(python)) |
| 17 |
return(python) |
| 18 |
} |
| 19 |
|
| 20 |
skip("python is not available") |
| 21 |
|
| 22 |
} |
| 23 |
|
| 24 |
skip_if_no_virtualenv <- function() { |
| 25 |
skip_if_no_python() |
| 26 |
skip_if_not(has_virtualenv(), "virtualenv module not installed") |
| 27 |
TRUE |
| 28 |
} |
| 29 |
|
| 30 |
the$has_virtualenv <- NULL |
| 31 |
has_virtualenv <- function() { |
| 32 |
the$has_virtualenv <- the$has_virtualenv %||% { |
| 33 |
python <- sys_python() |
| 34 |
version <- renv_python_version(python) |
| 35 |
module <- if (numeric_version(version) >= "3.2") "venv" else "virtualenv" |
| 36 |
renv_python_module_available(python, module) |
| 37 |
} |
| 38 |
} |
| 39 |
|
| 40 |
skip_if_no_miniconda <- function(min_version = NULL) { |
| 41 |
skip_if_no_python() |
| 42 |
|
| 43 |
if (!is.null(min_version)) { |
| 44 |
has_version <- renv_version_ge(renv_python_version(sys_python()), min_version) |
| 45 |
skip_if_not(has_version, paste0("python ", min_version, " not installed")) |
| 46 |
} |
| 47 |
|
| 48 |
skip_if_not_installed("reticulate", "1.28") |
| 49 |
path <- reticulate::miniconda_path() |
| 50 |
skip_if_not(file.exists(path), "miniconda is not installed") |
| 51 |
} |
| 52 |
|
| 53 |
skip_if_local <- function() { |
| 54 |
ci <- Sys.getenv("CI", unset = NA) |
| 55 |
testthat::skip_if(is.na(ci), "Running tests locally") |
| 56 |
} |
| 57 |
|
| 58 |
skip_on_windows <- function() { |
| 59 |
testthat::skip_on_os("windows") |
| 60 |
} |