Running 'DevEvalFileProduct.R' [1s]
  Running 'DevEvalProduct.R' [1s]
  Running 'capabilitiesX11.R' [173s]
  Running 'capturePlot.R' [2s]
  Running 'dataURI.R' [148s]
  Running 'devAll.R' [0s]
  Running 'devDump.R' [169s]
  Running 'devEqualTypes.R' [168s]
  Running 'devEval,error.R' [159s]
  Running 'devEval.R' [3s]
  Running 'devIsInteractive.R' [0s]
  Running 'devIsOpen.R' [170s]
  Running 'devList.R' [0s]
  Running 'devListIndexOf.R' [0s]
  Running 'devNew.R' [158s]
  Running 'devOptions.R' [1s]
  Running 'devSet.R' [1s]
  Running 'devTypeName.R' [1s]
  Running 'favicon.R' [1s]
  Running 'toNNN.R' [1s]
  Running 'withPar.R' [1s]
Running the tests in 'tests/capabilitiesX11.R' failed.
Complete output:
  > message("*** capabilitiesX11() ...")
  *** capabilitiesX11() ...
  > 
  > res <- R.devices::capabilitiesX11()
  > print(res)
  [1] FALSE
  > 
  > res2 <- R.devices::capabilitiesX11()
  > stopifnot(identical(res2, res))
  > 
  > res3 <- R.devices::capabilitiesX11(reset=TRUE)
  > print(res3)
  [1] FALSE
  > 
  > message("*** capabilitiesX11() ... DONE")
  *** capabilitiesX11() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.28    0.20    1.12 
Running the tests in 'tests/dataURI.R' failed.
Complete output:
  > message("*** dataURI ...")
  *** dataURI ...
  > 
  > R.devices::devOptions("*", field="dataURI")
  > uri <- R.devices::toPNG("foo", tags=c("a", "b"), aspectRatio=0.7, {
  +   plot(1:10)
  + })
  > str(uri)
   chr "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFQCAMAAABQwF3SAAAAclBMVEUAAAAAADoAAGYAOjoAOmYAOpAAZrY6AAA6A"| __truncated__
  > 
  > 
  > R.devices::devOptions("*", field="pathname")
  > png <- R.devices::toPNG("foo", tags=c("a", "b"), aspectRatio=0.7, {
  +   plot(1:10)
  + }, force=FALSE)
  > uri2 <- R.devices::asDataURI(png)
  > str(uri2)
   chr "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAeAAAAFQCAMAAABQwF3SAAAAclBMVEUAAAAAADoAAGYAOjoAOmYAOpAAZrY6AAA6A"| __truncated__
  > stopifnot(identical(uri2, uri))
  > 
  > message("*** dataURI ... DONE")
  *** dataURI ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.39    0.09    0.70 
Running the tests in 'tests/devDump.R' failed.
Complete output:
  > message("*** devDump() ...")
  *** devDump() ...
  > 
  > library("R.devices")
  R.devices v2.17.2 (2024-01-29 13:30:11 UTC) successfully loaded. See ?R.devices for help.
  > graphics.off()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Copy content of current screen device
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > if (interactive()) {
  +   # Open device
  +   plot(1:10)
  + 
  +   devList0 <- devList()
  +   devEval("png,jpg,pdf", name="count", tags="copy")
  +   stopifnot(all.equal(devList(), devList0))
  + 
  +   # Sanity checks
  +   print(devList())
  +   stopifnot(length(devList()) == 1L)
  + 
  + 
  +   # Same using a default name
  +   devList0 <- devList()
  +   devEval("png,jpg,pdf")
  +   stopifnot(all.equal(devList(), devList0))
  +   stopifnot(length(devList()) == 1L)
  + 
  +   # Close device
  +   devOff()
  + 
  +   stopifnot(length(devList()) == 0L)
  + 
  + 
  +   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +   # Copy content of all screen devices
  +   # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  +   # Open several devices
  +   idxs <- NULL
  + 
  +   idxs <- c(idxs, devNew())
  +   plot(1:10)
  + 
  +   idxs <- c(idxs, devNew())
  +   plot(cos)
  + 
  +   # Automatially "dump" image files of all open devices
  +   devDump()
  + 
  +   # "Manual" saving of defined
  +   which <- devList()
  +   print(which)
  + 
  +   # Save all
  +   devEval("png,pdf", which=which)
  + 
  +   # Close all opened devices
  +   devOff(idxs)
  + } # if (interactive())
  > 
  > 
  > message("*** devDump() ... DONE")
  *** devDump() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.43    0.10    0.48 
Running the tests in 'tests/devEqualTypes.R' failed.
Complete output:
  > library("R.devices")
  R.devices v2.17.2 (2024-01-29 13:30:11 UTC) successfully loaded. See ?R.devices for help.
  > devEqualTypes <- R.devices:::.devEqualTypes
  > png <- grDevices::png
  > postscript <- grDevices::postscript
  > 
  > message("*** devEqualTypes() ...")
  *** devEqualTypes() ...
  > 
  > message("*** devEqualTypes('png', 'png') ...")
  *** devEqualTypes('png', 'png') ...
  > res <- devEqualTypes("png", "png")
  > stopifnot(res)
  > 
  > message("*** devEqualTypes('png', png) ...")
  *** devEqualTypes('png', png) ...
  > res <- devEqualTypes("png", png)
  > stopifnot(res)
  > 
  > message("*** devEqualTypes(png, 'png') ...")
  *** devEqualTypes(png, 'png') ...
  > res <- devEqualTypes(png, "png")
  > stopifnot(res)
  > 
  > message("*** devEqualTypes(foo, png) ...")
  *** devEqualTypes(foo, png) ...
  > foo <- png
  > res <- devEqualTypes(foo, png)
  > stopifnot(res)
  > 
  > message("*** devEqualTypes('png', postscript) ...")
  *** devEqualTypes('png', postscript) ...
  > res <- devEqualTypes("png", postscript)
  > stopifnot(!res)
  > 
  > message("*** devEqualTypes(postscript, 'png') ...")
  *** devEqualTypes(postscript, 'png') ...
  > res <- devEqualTypes(postscript, "png")
  > stopifnot(!res)
  > 
  > message("*** devEqualTypes('non-existing', png) ...")
  *** devEqualTypes('non-existing', png) ...
  > res <- devEqualTypes("non-existing", png)
  > stopifnot(!res)
  > 
  > message("*** devEqualTypes(png, 'non-existing') ...")
  *** devEqualTypes(png, 'non-existing') ...
  > res <- devEqualTypes(png, "non-existing")
  > stopifnot(!res)
  > 
  > message("*** devEqualTypes(nulldev, 'nulldev') ...")
  *** devEqualTypes(nulldev, 'nulldev') ...
  > res <- devEqualTypes(nulldev, "nulldev")
  > stopifnot(res)
  > 
  > message("*** devEqualTypes() ... DONE")
  *** devEqualTypes() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.40    0.17    0.56 
Running the tests in 'tests/devEval,error.R' failed.
Complete output:
  > message("*** devEval() - errors ...")
  *** devEval() - errors ...
  > 
  > library("R.devices")
  R.devices v2.17.2 (2024-01-29 13:30:11 UTC) successfully loaded. See ?R.devices for help.
  > hpaste <- R.utils::hpaste
  > graphics.off()
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Error handling: Incomplete image file is removed
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > path <- getDevOption("pdf", "path")
  > files0 <- dir(path=path)
  > 
  > tryCatch({
  +   res <- devEval(type="pdf", name="error", {
  +     plot(1:10)
  +     v <- log("0")
  +     abline(v=v)
  +   }, onIncomplete="remove")
  +   print(res)
  + }, error = function(ex) {
  +   message("An error occurred while plotting: ", ex$message)
  + })
  An error occurred while plotting: non-numeric argument to mathematical function
  > 
  > ## Assert that any image created was removed
  > files <- dir(path=path)
  > new <- setdiff(files, files0)
  > if (length(new) > 0L) {
  +   stop("Failed to remove incomplete image file: ", hpaste(sQuote(new)))
  + }
  > 
  > 
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > # Error handling: Incomplete image file is renamed
  > # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
  > path <- getDevOption("pdf", "path")
  > 
  > ## Try many times to test unique renaming of files.
  > for (kk in 1:5) {
  +   files0 <- dir(path=path)
  +   tryCatch({
  +     res <- devEval(type="pdf", name="error", {
  +       plot(1:10)
  +       v <- log("0")
  +       abline(v=v)
  +     }, onIncomplete="rename")
  +     print(res)
  +   }, error = function(ex) {
  +     message("An error occurred while plotting: ", ex$message)
  +   })
  + 
  +   ## Assert that any image created was removed
  +   files <- dir(path=path)
  +   new <- setdiff(files, files0)
  +   if (length(new) != 1L) {
  +     stop("Failed to rename incomplete image file")
  +   }
  +   cat("Incomplete image file: ", new, "\n", sep="")
  + }
  An error occurred while plotting: non-numeric argument to mathematical function
  Incomplete image file: error,INCOMPLETE_001.pdf
  An error occurred while plotting: non-numeric argument to mathematical function
  Incomplete image file: error,INCOMPLETE_002.pdf
  An error occurred while plotting: non-numeric argument to mathematical function
  Incomplete image file: error,INCOMPLETE_003.pdf
  An error occurred while plotting: non-numeric argument to mathematical function
  Incomplete image file: error,INCOMPLETE_004.pdf
  An error occurred while plotting: non-numeric argument to mathematical function
  Incomplete image file: error,INCOMPLETE_005.pdf
  > 
  > # Sanity checks
  > print(devList())
  named integer(0)
  > stopifnot(length(devList()) == 0L)
  > 
  > message("*** devEval() - errors ... DONE")
  *** devEval() - errors ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.64    0.14    1.50 
Running the tests in 'tests/devIsOpen.R' failed.
Complete output:
  > message("*** devIsOpen() ...")
  *** devIsOpen() ...
  > 
  > library("R.devices")
  R.devices v2.17.2 (2024-01-29 13:30:11 UTC) successfully loaded. See ?R.devices for help.
  > 
  > for (which in list(c(), 1L, 1:5)) {
  +   print(which)
  +   res <- devIsOpen(which)
  +   print(res)
  +   stopifnot(is.logical(res))
  +   stopifnot(is.character(names(res)))
  +   stopifnot(length(res) == length(which))
  + }
  NULL
  named logical(0)
  [1] 1
  Device 1 
      TRUE 
  [1] 1 2 3 4 5
  Device 1     <NA>     <NA>     <NA>     <NA> 
      TRUE    FALSE    FALSE    FALSE    FALSE 
  > 
  > message("*** devIsOpen() ... DONE")
  *** devIsOpen() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.34    0.10    0.45 
Running the tests in 'tests/devNew.R' failed.
Complete output:
  > message("*** devNew() ...")
  *** devNew() ...
  > 
  > library("R.devices")
  R.devices v2.17.2 (2024-01-29 13:30:11 UTC) successfully loaded. See ?R.devices for help.
  > 
  > 
  > message("*** devNew(which=which) ...")
  *** devNew(which=which) ...
  > 
  > idx <- devNew()
  > plot(1:10)
  > idx2 <- devNew(which=idx)
  > plot(1:10)
  > devOff(idx2)
  pdf 
    2 
  > if (idx2 != idx) devOff(idx)
  null device 
            1 
  > 
  > message("*** devNew(which=which) ... DONE")
  *** devNew(which=which) ... DONE
  > 
  > 
  > message("*** devNew(aspectRatio) ...")
  *** devNew(aspectRatio) ...
  > ## Height is inferred
  > devNew(width=10, aspectRatio=1.5)
  > plot(1:10)
  > devOff()
  null device 
            1 
  > 
  > ## Width is inferred
  > devNew(height=10, aspectRatio=1.5)
  > plot(1:10)
  > devOff()
  null device 
            1 
  > message("*** devNew(aspectRatio) ... DONE")
  *** devNew(aspectRatio) ... DONE
  > 
  > 
  > message("*** devNew(scale) ...")
  *** devNew(scale) ...
  > 
  > devNew(width=10, scale=1.5)
  > plot(1:10)
  > devOff()
  null device 
            1 
  > 
  > devNew(height=10, scale=1.5)
  > plot(1:10)
  > devOff()
  null device 
            1 
  > 
  > ## Force 'width' from device options
  > devNew(aspectRatio=NULL, scale=1.5)
  > plot(1:10)
  > devOff()
  null device 
            1 
  > 
  > message("*** devNew(scale) ... DONE")
  *** devNew(scale) ... DONE
  > 
  > 
  > message("*** devNew() - warnings ...")
  *** devNew() - warnings ...
  > 
  > ok <- tryCatch({
  +   devNew(width=10, height=10, aspectRatio=1.5)
  +   FALSE
  + }, warning = function(warn) {
  +   print(warn)
  +   TRUE
  + })
  <simpleWarning in devNew(width = 10, height = 10, aspectRatio = 1.5): Argument 'aspectRatio' was ignored because both 'width' and 'height' were given: 1.5>
  > stopifnot(ok)
  > 
  > res <- try(devNew(par=list(1)))
  Error in devNew(par = list(1)) : 
    Argument 'par' has to be a named list: list
  > stopifnot(inherits(res, "try-error"))
  > 
  > message("*** devNew() - warnings ... DONE")
  *** devNew() - warnings ... DONE
  > 
  > 
  > message("*** devNew() - errors ...")
  *** devNew() - errors ...
  > 
  > res <- try(devNew(par=c(pch=1)))
  Error in devNew(par = c(pch = 1)) : 
    Argument 'par' has to be a named list: numeric
  > stopifnot(inherits(res, "try-error"))
  > 
  > res <- try(devNew(par=list(1)))
  Error in devNew(par = list(1)) : 
    Argument 'par' has to be a named list: list
  > stopifnot(inherits(res, "try-error"))
  > 
  > devNew(label="foo")
  > plot(1:10)
  > res <- try(devNew(label="foo"))
  Error in devNew(label = "foo") : 
    Cannot open device. Label is already used: foo
  > stopifnot(inherits(res, "try-error"))
  > devOff()
  null device 
            1 
  > 
  > message("*** devNew() - errors ... DONE")
  *** devNew() - errors ... DONE
  > 
  > message("*** devOff() ... ")
  *** devOff() ... 
  > 
  > ## Open and close device
  > idx0 <- devNew()
  > idx1 <- devOff(idx0)
  > str(idx1)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > ## Close same device again (should silently return)
  > idx2 <- devOff(idx0)
  > str(idx2)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > stopifnot(identical(idx2, idx1))
  > 
  > ## Close many devices
  > idx3 <- devOff(2:5)
  > str(idx3)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > message("*** devOff() ... DONE")
  *** devOff() ... DONE
  > 
  > 
  > message("*** devDone() ... ")
  *** devDone() ... 
  > 
  > ## Open and close device
  > idx0 <- devNew()
  > idx1 <- devDone(idx0)
  > str(idx1)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > ## Close same device again (should silently return)
  > idx2 <- devDone(idx0)
  > str(idx2)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > stopifnot(identical(idx2, idx1))
  > 
  > ## Close many devices
  > idx3 <- devDone(1:5)
  > str(idx3)
   Named int 1
   - attr(*, "names")= chr "null device"
  > 
  > message("*** devDone() ... DONE")
  *** devDone() ... DONE
  > 
  > message("*** devNew() ... DONE")
  *** devNew() ... DONE
  > 
  > proc.time()
     user  system elapsed 
     0.43    0.21    0.60