Running ‘testthat.R’ [2s/3s]
Running the tests in ‘tests/testthat.R’ failed.
Complete output:
  > library(testthat)
  > library(ReporteRs)
  Loading required package: ReporteRsjars
  > 
  > test_check("ReporteRs")
  ── 1. Error: (unknown) (@test-docx-bookmarks.R#4)  ─────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("bookmark is kept and stylename is used", {
         target_file <- tempfile(fileext = ".docx")
         target_dir <- tempfile(fileext = "")
         template <- system.file(package = "ReporteRs", "templates/bookmark_example.docx")
         doc <- docx(template = template)
         doc <- addParagraph(doc, value = "ipsem", stylename = "figurereference", bookmark = "DATA") %>% 
             addPlot(fun = function(x) barplot(1:9), bookmark = "PLOT")
         writeDoc(doc, target_file)
         unzip(zipfile = target_file, exdir = target_dir)
         doc <- read_xml(file.path(target_dir, "word/document.xml"))
         bkm <- xml_find_first(doc, ".//w:bookmarkStart[@w:name='PLOT']")
         expect_false(inherits(bkm, "xml_missing"))
         bkm <- xml_find_first(doc, ".//w:bookmarkStart[@w:name='DATA']")
         expect_false(inherits(bkm, "xml_missing"))
         pstyle <- bkm %>% xml_parent() %>% xml_find_first("w:pPr/w:pStyle")
         expect_equivalent(xml_attr(pstyle, "val"), "figurereference")
     }) at testthat/test-docx-bookmarks.R:4
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 2. Error: (unknown) (@test-docx-img.R#8)  ───────────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("[docx] image with no size generate an error", {
         doc <- docx()
         doc <- try(addImage(doc, "img.png"), silent = TRUE)
         expect_is(doc, "try-error")
     }) at testthat/test-docx-img.R:8
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 3. Error: (unknown) (@test-docx-plot.R#10)  ─────────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("[vg] no size generate no error", {
         doc <- docx()
         doc <- try(addPlot(doc, fun = dummy_plot, vector.graphic = TRUE), silent = TRUE)
         expect_is(doc, "docx")
     }) at testthat/test-docx-plot.R:10
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 4. Error: (unknown) (@test-file-extensions.R#3)  ────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("pptx extension must be pptx", {
         doc <- pptx()
         doc <- addSlide(doc, "Title and Content")
         res <- try(writeDoc(doc, "doc_1.pptx"), silent = TRUE)
         expect_null(res)
         doc <- pptx()
         doc <- addSlide(doc, "Title and Content")
         res <- try(writeDoc(doc, "doc_1.ppt"), silent = TRUE)
         expect_is(res, "try-error")
     }) at testthat/test-file-extensions.R:3
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 5. Error: (unknown) (@test-flextable.R#30)  ─────────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("header rows", {
         row1 <- c("Sepal", "Petal", "")
         row2 <- c("Length", "Width", "Length", "Width", "Species")
         ft1 <- FlexTable(data = iris[46:55, ], header.columns = FALSE)
         ft1 <- addHeaderRow(ft1, value = row1, colspan = c(2, 2, 1))
         ft1 <- addHeaderRow(ft1, value = row2)
         ft2 <- FlexTable(data = iris[46:55, ], header.columns = TRUE)
         ft2 <- addHeaderRow(ft2, value = row1, colspan = c(2, 2, 1), first = TRUE)
         target_dir <- pptx_doc(flextable = ft1)
         doc <- read_xml(file.path(target_dir, "ppt/slides/slide1.xml"))
         xml_path_0 <- c("/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData", 
             "/a:tbl/a:tr[1]", "/a:tc/a:txBody/a:p/a:r/a:t")
         xml_path_ <- paste(xml_path_0, collapse = "")
         hvalues <- xml_find_all(doc, xml_path_) %>% xml_text()
         expect_equal(hvalues, row1)
         xml_path_0 <- c("/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData", 
             "/a:tbl/a:tr[1]", "/a:tc")
         xml_path_ <- paste(xml_path_0, collapse = "")
         expect_length(xml_find_all(doc, xml_path_), 5)
         xml_path_0 <- c("/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData", 
             "/a:tbl/a:tr[1]", "/a:tc")
         xml_path_ <- paste(xml_path_0, collapse = "")
         nodes <- xml_find_all(doc, xml_path_)
         expect_equal(nodes %>% xml_attr(attr = "gridSpan"), c("2", NA, "2", NA, NA))
         expect_equal(nodes %>% xml_attr(attr = "hMerge"), c(NA, "true", NA, "true", NA))
         xml_path_1 <- xml_path_0[2] <- "/a:tbl/a:tr[2]"
         xml_path_ <- paste(xml_path_0, collapse = "")
         hvalues <- xml_find_all(doc, xml_path_) %>% xml_text()
         expect_equal(hvalues, row2)
         target_dir <- pptx_doc(flextable = ft2)
         doc <- read_xml(file.path(target_dir, "ppt/slides/slide1.xml"))
         xml_path_0 <- c("/p:sld/p:cSld/p:spTree/p:graphicFrame/a:graphic/a:graphicData", 
             "/a:tbl/a:tr[1]", "/a:tc/a:txBody/a:p/a:r/a:t")
         xml_path_ <- paste(xml_path_0, collapse = "")
         hvalues <- xml_find_all(doc, xml_path_) %>% xml_text()
         expect_equal(hvalues, row1)
         xml_path_1 <- xml_path_0[2] <- "/a:tbl/a:tr[2]"
         xml_path_ <- paste(xml_path_0, collapse = "")
         hvalues <- xml_find_all(doc, xml_path_) %>% xml_text()
         expect_equal(hvalues, names(iris))
         target_dir <- docx_doc(flextable = ft1)
         doc <- read_xml(file.path(target_dir, "word/document.xml"))
         header_rows <- xml_find_all(doc, "/w:document/w:body/w:tbl/w:tr[./w:trPr/w:tblHeader]")
         hvalues <- lapply(paste0(sapply(header_rows, xml_path), "/w:tc/w:p/w:r/w:t"), 
             function(x) xml_find_all(doc, x) %>% xml_text())
         expect_equal(hvalues[[1]], row1)
         expect_equal(hvalues[[2]], row2)
         xml_path_0 <- c("/w:document/w:body/w:tbl/w:tr[./w:trPr/w:tblHeader]", "[1]/w:tc")
         xml_path_ <- paste(xml_path_0, collapse = "")
         nodes <- xml_find_all(doc, xml_path_)
         expect_length(nodes, 3)
         xml_path_0 <- c("/w:document/w:body/w:tbl/w:tr[./w:trPr/w:tblHeader]", "[1]/w:tc/w:tcPr/w:gridSpan")
         xml_path_ <- paste(xml_path_0, collapse = "")
         nodes <- xml_find_all(doc, xml_path_)
         expect_equal(nodes %>% xml_attr(attr = "val"), c("2", "2"))
         target_dir <- docx_doc(flextable = ft2)
         doc <- read_xml(file.path(target_dir, "word/document.xml"))
         header_rows <- xml_find_all(doc, "/w:document/w:body/w:tbl/w:tr[./w:trPr/w:tblHeader]")
         hvalues <- lapply(paste0(sapply(header_rows, xml_path), "/w:tc/w:p/w:r/w:t"), 
             function(x) xml_find_all(doc, x) %>% xml_text())
         expect_equal(hvalues[[1]], row1)
         expect_equal(hvalues[[2]], names(iris))
     }) at testthat/test-flextable.R:30
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 6. Error: (unknown) (@test-pptx-img.R#9)  ───────────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("no position no size generate no error", {
         skip_on_os("solaris")
         doc <- pptx()
         doc <- addSlide(doc, "Title and Content")
         doc <- try(addImage(doc, "img.png"), silent = TRUE)
         expect_is(doc, "pptx")
     }) at testthat/test-pptx-img.R:9
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ── 7. Error: (unknown) (@test-pptx-plot.R#10)  ─────────────────────────────────
  no field, method or inner class called 'handled' 
  1: test_that("[vg] no position no size generate no error", {
         doc <- pptx()
         doc <- addSlide(doc, "Title and Content")
         doc <- try(addPlot(doc, fun = dummy_plot, vector.graphic = TRUE), silent = TRUE)
         expect_is(doc, "pptx")
     }) at testthat/test-pptx-plot.R:10
  2: test_code(desc, code, env = parent.frame())
  3: tryCatch(withCallingHandlers({
         eval(code, test_env)
         if (!handled && !is.null(test)) {
             skip_empty()
         }
     }, expectation = handle_expectation, skip = handle_skip, warning = handle_warning, 
         message = handle_message, error = handle_error), error = handle_fatal, skip = function(e) {
     })
  4: tryCatchList(expr, classes, parentenv, handlers)
  5: tryCatchOne(tryCatchList(expr, names[-nh], parentenv, handlers[-nh]), names[nh], 
         parentenv, handlers[[nh]])
  6: doTryCatch(return(expr), name, parentenv, handler)
  7: tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
  8: tryCatchOne(expr, names, parentenv, handlers[[1L]])
  9: value[[3L]](cond)
  10: isTRUE(e$handled)
  11: e$handled
  12: `$.Throwable`(e, "handled")
  13: ._jobjRef_dollar(x[["jobj"]], name)
  14: stop(sprintf("no field, method or inner class called '%s' ", name))
  
  ══ testthat results  ═══════════════════════════════════════════════════════════
  OK: 4 SKIPPED: 0 FAILED: 7
  1. Error: (unknown) (@test-docx-bookmarks.R#4) 
  2. Error: (unknown) (@test-docx-img.R#8) 
  3. Error: (unknown) (@test-docx-plot.R#10) 
  4. Error: (unknown) (@test-file-extensions.R#3) 
  5. Error: (unknown) (@test-flextable.R#30) 
  6. Error: (unknown) (@test-pptx-img.R#9) 
  7. Error: (unknown) (@test-pptx-plot.R#10) 
  
  Error: testthat unit tests failed
  Execution halted