Skip to content

Commit b18997f

Browse files
committed
add ability to run orca via xvfb-run and use it on travis
1 parent 22b0b83 commit b18997f

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

.travis.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ matrix:
88
include:
99
- r: devel
1010
- r: release
11-
env: USE_VDIFFR=true
11+
env:
12+
- USE_VDIFFR=true
13+
- USE_XVFB=true
1214
- r: oldrel
1315

1416
env:

R/orca.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ orca <- function(p, file = "plot.png", format = tools::file_ext(file),
117117
#' }
118118
#' \item{\code{quiet}}{Suppress all logging info.}
119119
#' \item{\code{debug}}{Starts app in debug mode.}
120+
#' \item{\code{xvfb}}{Whether to run orca via X virtual framebuffer. May be necessary in a headless environment}
120121
#' }
121122
#'
122123
#' @section Methods:
@@ -167,7 +168,7 @@ orca_serve <- R6::R6Class(
167168
port = NULL,
168169
initialize = function(port = 5151, mathjax = FALSE, safe = FALSE, request_limit = NULL,
169170
keep_alive = TRUE, window_max_number = NULL, quiet = FALSE,
170-
debug = FALSE, ...) {
171+
debug = FALSE, xvfb = FALSE, ...) {
171172

172173
# make sure we have the required infrastructure
173174
orca_available()
@@ -200,7 +201,12 @@ orca_serve <- R6::R6Class(
200201
if (isTRUE(mathjax))
201202
args <- c(args, "--mathjax", file.path(mathjax_path(), "MathJax.js"))
202203

203-
self$process <- processx::process$new("orca", args, ...)
204+
if (xvfb) {
205+
self$process <- processx::process$new("xvfb-run", c("orca", args), ...)
206+
} else {
207+
self$process <- processx::process$new("orca", args, ...)
208+
}
209+
204210
self$port <- port
205211
},
206212
export = function(p, file = "plot.png", format = tools::file_ext(file), scale = NULL, width = NULL, height = NULL) {

man/orca_serve.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/helper-vdiffr.R

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,17 @@ if (!requireNamespace("vdiffr", quietly = TRUE) ||
1818
if (enable_vdiffr) {
1919
# generate random (port) number between 3000 & 8000
2020
port <- floor(runif(1, 3001, 8000))
21-
22-
# try and start up the node process
21+
# make sure orca cli is available
2322
orca_available()
24-
orcaImageServer <- try(orca_serve$new(port), silent = TRUE)
23+
# try and start up the node process
24+
orcaImageServer <- try(orca_serve$new(port, xvfb = Sys.getenv("USE_XVFB", FALSE)), silent = TRUE)
2525
if (inherits(orcaImageServer, 'try-error')) {
2626
stop(
2727
"Tried to open orca server on port '", port, "', but it's not available. ",
2828
"Try (possibly restarting R) and running `test()` again"
2929
)
3030
}
3131

32-
3332
# define logic for writing svg in vdiffr
3433
write_svg.plotly <- function(p, file, title, user_fonts = NULL) {
3534
# before exporting, specify trace[i].uid so resulting svg is deterministic

0 commit comments

Comments
 (0)