This file is indexed.

/usr/lib/R/site-library/BiocInstaller/unitTests/test_package_update.R is in r-bioc-biocinstaller 1.24.0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
test_package_filter_suppress_updates <- function() {
    .filter <- BiocInstaller:::.package_filter_suppress_updates

    pkgs0 <- matrix(
        character(), 0, 2,
        dimnames=list(NULL, c("Package", "LibPath")))

    checkIdentical(pkgs0, .filter(pkgs0, FALSE))
    checkIdentical(pkgs0, .filter(pkgs0, character()))

    p0 <- tempdir()
    pkgs <- matrix(
        c("Foo", "Bar", "Baz", p0, p0, p0), 3, 2,
        dimnames=list(c("Foo", "Bar", "Baz"), c("Package", "LibPath")))

    checkIdentical(pkgs, .filter(pkgs, FALSE))
    checkIdentical(pkgs[3,,drop=FALSE], .filter(pkgs, c("Foo", "Bar")))
    checkIdentical(pkgs0, .filter(pkgs, c("Foo", "Bar", "Baz")))
    checkIdentical(pkgs0, .filter(pkgs, ""))
}

test_package_filter_masked <- function() {
    .filter <- BiocInstaller:::.package_filter_masked

    pkgs0 <- matrix(
        character(), 0, 2,
        dimnames=list(NULL, c("Package", "LibPath")))

    checkIdentical(pkgs0, .filter(pkgs0))

    paths <- c(tempfile(), tempfile())
    for (path in paths) dir.create(path)
    oLibPaths <- .libPaths()
    on.exit(.libPaths(oLibPaths))
    .libPaths(paths)

    pkgs <- matrix(
        c("Foo", "Bar", "Baz", "Bim", paths, paths), 4, 2,
        dimnames=list(c("Foo", "Bar", "Baz", "Bim"), c("Package", "LibPath")))
    checkIdentical(pkgs, .filter(pkgs))
    checkIdentical(pkgs[c(1, 3, 2),], .filter(pkgs[c(1, 3, 2),]))

    pkgs <- matrix(
        c("Foo", "Bar", "Foo", paths, paths[2]), 3, 2,
        dimnames=list(c("Foo", "Bar", "Foo"), c("Package", "LibPath")))
    checkIdentical(pkgs[1:2,], .filter(pkgs))
    pkgs <- pkgs[3:1,]
    checkIdentical(pkgs[2:3,], .filter(pkgs))
}

test_package_filter_unwriteable <- function() {
    .filter <- BiocInstaller:::.package_filter_unwriteable

    ## setup
    dir.create(p0 <- tempfile())
    on.exit(unlink(p0, recursive=TRUE))

    pkgs0 <- matrix(
        character(), 0, 2,
        dimnames=list(NULL, c("Package", "LibPath")))

    pkgs <- pkgs0
    checkIdentical(pkgs, .filter(pkgs, NULL))
    checkIdentical(pkgs, .filter(pkgs, character()))
    checkIdentical(pkgs, .filter(pkgs, tempdir()))

    pkgs <- matrix(c("Foo", p0), 1, byrow=TRUE,
                   dimnames=list("Foo", c("Package", "LibPath")))
    checkIdentical(pkgs, .filter(pkgs, NULL))
    checkIdentical(pkgs, .filter(pkgs, p0))

    p1 <- tempfile()
    pkgs <- matrix(c("Foo", p1), 1, byrow=TRUE,
                   dimnames=list("Foo", c("Package", "LibPath")))
    checkIdentical(pkgs[FALSE,, drop=FALSE], .filter(pkgs, NULL))
    checkIdentical(pkgs[FALSE,, drop=FALSE], .filter(pkgs, p1))
    checkIdentical(pkgs, .filter(pkgs, p0))

    pkgs <- matrix(
        c("Foo", p0, "Bar", p1, "Baz", p0), 3, 2, byrow=TRUE,
        dimnames=list(c("Foo", "Bar", "Baz"), c("Package", "LibPath")))
    checkIdentical(pkgs[c(1, 3),], .filter(pkgs, NULL))
    checkIdentical(pkgs, .filter(pkgs, p0))
    checkIdentical(pkgs0, .filter(pkgs, p1))

    msg <- tryCatch(.filter(pkgs, NULL), message=conditionMessage)
    checkIdentical(
        "installation path not writeable, unable to update packages: Bar\n",
        msg)

    if (.Platform$OS.type == "windows")
        ## how to create a read-only directory?
        return(TRUE)

    dir.create(p2 <- tempfile(), mode="0400") # read but not write
    pkgs <- matrix(c("Foo", p2), 1, byrow=TRUE,
                   dimnames=list("Foo", c("Package", "LibPath")))
    checkIdentical(pkgs0, .filter(pkgs, NULL))

    pkgs <- matrix(
        c("Foo", p0, "Bar", p2, "Baz", p0), 3, 2, byrow=TRUE,
        dimnames=list(c("Foo", "Bar", "Baz"), c("Package", "LibPath")))
    checkIdentical(pkgs[c(1, 3),], .filter(pkgs, NULL))
    checkIdentical(pkgs0, .filter(pkgs, p2))

    Sys.chmod(p2, mode="0700")
    unlink(p2, recursive=TRUE)
}

test_writeable_biocLite <- function() {
    DEACTIVATED("too idiosyncratic for standardized testing")

    lib <- system.file(package="BiocInstaller", "unitTests", "cases",
                       "lib", "Biobase")
    dir.create(locked <- tempfile())
    file.copy(lib, locked, recursive=TRUE)

    oLibPaths <- .libPaths()
    on.exit(.libPaths(oLibPaths))
    .libPaths(c(locked, .libPaths()))

    Sys.chmod(locked, mode="0500")
    biocLite()                          #
    Sys.chmod(locked, mode="0700")
}