File: test_logging.R

package info (click to toggle)
r-bioc-biocparallel 1.40.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,768 kB
  • sloc: cpp: 139; sh: 14; makefile: 8
file content (32 lines) | stat: -rw-r--r-- 1,033 bytes parent folder | download | duplicates (2)
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
message("Testing logging")

## This code tests 'log' and 'progressbar'. test_errorhandling.R
## tests 'stop.on.error'

test_log <- function()
{
    ## SnowParam, MulticoreParam only
    params <- list(
        snow=SnowParam(2, log=FALSE, stop.on.error=FALSE),
        snowLog=SnowParam(2, log=TRUE, stop.on.error=FALSE))
    if (.Platform$OS.type != "windows") {
        params$multi=MulticoreParam(3, log=FALSE, stop.on.error=FALSE)
        params$multiLog=MulticoreParam(3, log=TRUE, stop.on.error=FALSE)
    }

    for (param in params) {
        res <- suppressMessages(tryCatch({
            bplapply(list(1, "2", 3), sqrt, BPPARAM=param)
        }, error=identity))
        checkTrue(is(res, "bplist_error"))
        result <- bpresult(res)
        checkTrue(length(result) == 3L)
        msg <- "non-numeric argument to mathematical function"
        checkIdentical(conditionMessage(result[[2]]), msg)
        checkTrue(length(attr(result[[2]], "traceback")) > 0L)
    }

    ## clean up
    closeAllConnections()
    TRUE
}