diff --git a/Makefile b/Makefile index b6406295a..57f6f7637 100644 --- a/Makefile +++ b/Makefile @@ -22,7 +22,7 @@ test-ci: compress-fixtures | R --slave -e 'library(covr); install_dir <- tempfile(); test_run <- try(to_cobertura(package_coverage(quiet=FALSE, install_path=install_dir, clean=FALSE))); for (file in list.files(install_dir, pattern = "\\.Rout(\\.fail)?$$", recursive=TRUE, full.names=TRUE)) { cat(readLines(file), sep = "\n"); cat("\n") }; if (inherits(test_run, "try-error")) stop("Test failed!\n", attr(test_run, "condition")[["message"]], "\n", format(attr(test_run, "condition")[["call"]]))' test-ci-partial: compress-fixtures | - cd tests/ && R --slave -e 'library(devtools); library(testthat); test(filter="${file_regex}", reporter = MultiReporter$$new(list(SummaryReporter$$new(), JunitReporter$$new(file = file.path(Sys.getenv("WORKSPACE"), "rcrunch.xml"))))); cat("\n---\nPRINTING JUNIT FILE at ", file.path(Sys.getenv("WORKSPACE"), "rcrunch.xml"), "\n---\n", paste0(readLines(file.path(Sys.getenv("WORKSPACE"), "rcrunch.xml"))), "\n---\n")' + cd tests/ && R --slave -e 'library(devtools); source("../inst/junit_fix.R"); library(testthat); test(filter="${file_regex}", reporter = MultiReporter$$new(list(SummaryReporter$$new(), JunitReporterFix$$new(file = file.path(Sys.getenv("WORKSPACE"), "rcrunch.xml")))));' clean: R --slave -e 'library(crunch); set_crunch_opts(crunch.api=envOrOption("test.api"), crunch.api.key=envOrOption("crunch.test.api.key")); lapply(urls(datasets()), crDELETE)' diff --git a/inst/junit_fix.R b/inst/junit_fix.R new file mode 100644 index 000000000..d9778e4a5 --- /dev/null +++ b/inst/junit_fix.R @@ -0,0 +1,24 @@ +tt_read_lines <- function(path, n = -1L, encoding = "UTF-8") { + base::readLines(path, n = n, encoding = encoding, warn = FALSE) +} + +tt_write_lines <- function(text, path) { + base::writeLines(enc2utf8(text), path, useBytes = TRUE) +} + +# trick to get around :: from depends CRAN check +R6Class <- get("R6Class", asNamespace("R6")) + +JunitReporterFix <- R6Class( + "JunitReporterFix", + inherit = JunitReporter, + public = list( + end_reporter = function() { + super$end_reporter() + tt_write_lines( + crayon::strip_style(tt_read_lines(self$out)), + self$out + ) + } + ) +)