Debian Codegraph @

tests/testthat/test-sysreqs.R

raw
1
2 test_that("system requirements are reported", {
3
4 skip_on_cran()
5
6 renv_scope_binding(the, "os", "linux")
7
8 local({
9 renv_scope_binding(the, "distro", "ubuntu")
10 renv_scope_binding(the, "platform", list(VERSION_ID = "24.04"))
11 sysdep <- renv_sysreqs_resolve("zlib")
12 expect_equal(sysdep$packages, list("zlib1g-dev"))
13 })
14
15 local({
16 renv_scope_binding(the, "distro", "redhat")
17 renv_scope_binding(the, "platform", list(VERSION_ID = "9"))
18 sysdep <- renv_sysreqs_resolve("zlib")
19 expect_equal(sysdep$packages, list("zlib-devel"))
20 })
21
22 })
23
24 test_that("version constraints are respected", {
25
26 skip_on_cran()
27
28 renv_tests_scope()
29 renv_scope_binding(the, "os", "linux")
30
31 local({
32 renv_scope_binding(the, "distro", "rockylinux")
33 renv_scope_binding(the, "platform", list(VERSION_ID = "8"))
34 sysdep <- renv_sysreqs_resolve("libgit2")
35 expect_equal(sysdep$packages, list("libgit2_1.7-devel"))
36 })
37
38 local({
39 renv_scope_binding(the, "distro", "rockylinux")
40 renv_scope_binding(the, "platform", list(VERSION_ID = "9"))
41 sysdep <- renv_sysreqs_resolve("libgit2")
42 expect_equal(sysdep$packages, list("libgit2-devel"))
43 })
44
45 })
46
47 test_that("system requirements are reported as expected", {
48
49 skip_on_cran()
50 skip_if(!renv_platform_linux())
51 skip_if(!nzchar(Sys.which("dpkg-query")))
52
53 # check a package that is unlikely to be installed
54 status <- system("dpkg-query -W blender 2> /dev/null")
55 skip_if(status == 0L)
56
57 sysreqs <- list("<unknown>" = "blender")
58 expect_snapshot(
59 . <- renv_sysreqs_check(sysreqs, FALSE),
60 transform = function(x) gsub("sudo \\S+ \\S+", "sudo <install>", x)
61 )
62
63 })
64
65 test_that("system requirements for alternate distributions are reported", {
66
67 skip_on_cran()
68 skip_if(!renv_platform_linux())
69
70 packages <- c("magick", "tesseract")
71 expect_snapshot(
72 . <- sysreqs(packages, distro = "redhat:8"),
73 transform = function(x) gsub("\\[\\d+/\\d+\\] ", "", x)
74 )
75
76 })