Debian Codegraph @

tests/testthat/test-acls.R

raw
1
2 test_that("renv_acls_reset() can reset ACLs", {
3
4 skip_on_cran()
5 skip_if(!renv_platform_linux())
6 skip_if(!nzchar(Sys.which("getfacl")))
7 skip_if(!nzchar(Sys.which("setfacl")))
8
9 renv_scope_tempdir()
10
11 # create some directories
12 unlink("source", recursive = TRUE)
13 unlink("target", recursive = TRUE)
14
15 # in this scenario, we'll move 'source/directory' to 'target/directory',
16 # and check that the ACLs from 'target' are applied to 'target/directory'
17 # when all is said and done
18 dir.create("source")
19 dir.create("target")
20
21 # try setting some ACLs on the source directory;
22 # this basically disallows any 'other' access
23 system("setfacl -d -m o::- source")
24 dir.create("source/directory")
25
26 # try copying the directory; the ACLs should be copied
27 system("cp -R source/directory target/directory")
28
29 # try resetting its ACL
30 renv_acls_reset("target/directory")
31
32 # check that the permissions (via ACLs) were preserved
33 expect_equal(file.mode("target"), file.mode("target/directory"))
34
35 })