ff  ˆ¾‘äÇò 8àd��ŒAf6ÿŸÉ ƒh¹ÈÀÆ ff 5 ˆl–ß=¿J Õ5*�rãA¸ )‹Fÿ�þ^•Õ›)á%|OþÊ ƒŸoÉÁÇ÷ test_that("rscript", { out <- rscript("fixtures/script.R", show = FALSE) expect_equal(out$status, 0L) expect_equal( out$stdout, if (os_platform() == "windows") "stdout\r\n" else "stdout\n") expect_equal( out$stderr, if (os_platform() == "windows") "stderr\r\n" else "stderr\n") gc() }) test_that("rscript_process", { px <- rscript_process$new( rscript_process_options(script = "fixtures/script.R")) on.exit(try(px$kill(), silent = TRUE), add = TRUE) px$wait(5000) expect_equal(px$get_exit_status(), 0) expect_equal(px$read_output_lines(), "stdout") expect_equal(px$read_error_lines(), "stderr") rm(px); gc() }) test_that("stderr -> stdout", { out <- rscript("fixtures/script2.R", show = FALSE, stderr = "2>&1") exp <- if (os_platform() == "windows") { "out1err1out2err2\r\n" } else { "out1err1out2err2\n" } expect_equal(out$stdout, exp) expect_null(out$stderr) out2 <- test_temp_file(create = FALSE) rscript("fixtures/script2.R", show = FALSE, stdout = out2, stderr = out2) expect_equal(readLines(out2), "out1err1out2err2") gc() }) test_that("cleans up temporary files", { skip_on_cran() rsc <- function() { library(callr) scriptfile <- tempfile(fileext = ".R") cat("cat('foobar')\n", file = scriptfile) old <- dir(tempdir(), pattern = "^callr-") result <- callr::rscript(scriptfile) new <- setdiff(dir(tempdir(), "^callr-"), old) list(result = result, new = new) } out <- r(rsc) expect_identical(out$result$stdout, "foobar") expect_identical(out$new, character()) }) test_that("bg process cleans up temporary files", { skip_on_cran() rsc <- function() { library(callr) scriptfile <- tempfile(fileext = ".R") cat("cat('foobar')\n", file = scriptfile) old <- dir(tempdir(), pattern = "^callr-") opts <- rscript_process_options(script = scriptfile) rp <- rscript_process$new(opts) on.exit(tryCatch(rp$kill, error = function(e) NULL), add = TRUE) rp$wait(5000) result <- rp$read_output() rp$kill() rm(rp) gc() gc() new <- setdiff(dir(tempdir(), "^callr-"), old) list(result = result, new = new) } out <- r(rsc) expect_identical(out$result, "foobar") expect_identical(out$new, character()) }) 7ˆÆ�þYd ¬Ü¢#Í¿(žhþÊ „ p?Éa–Ü4ý(Ô¾R( ÅÕÀ†ão©‹FÿÈ3 -- Table to store footnotes, so they can be included at the end. local notes = {} -- Rendering state local in_slide = false local build_slide = false local in_notes = false -- Character escaping local function escape(s, in_attribute) s = s:gsub("[<>&\"']", function(x) if x == '<' then return '<' elseif x == '>' then return '>' elseif x == '&' then return '&' elseif x == '"' then return '"' elseif x == "'" then return ''' else return x end end) return s end -- Helper function to convert an attributes table into -- a string that can be put into HTML tags. local function attributes(attr) local attr_table = {} for x,y in pairs(attr) do if y and y ~= "" then table.insert(attr_table, ' ' .. x .. '="' .. escape(y,true) .. '"') end end return table.concat(attr_table) end -- Helper function to split a string on spaces -- returns a table local function split(str) local words = {} for word in str:gmatch("%S+") do table.insert(words, word) end return words end -- Helper function to remove duplicates -- returns a table http://stackoverflow.com/a/20067270 local function uniq(t) local seen = {} local res = {} for _,v in ipairs(t) do if (not seen[v]) then res[#res+1] = v seen[v] = true end end return res end -- Helper function to filter a list -- returns a table local function grep(f, l) local res = {} for _,v in ipairs(l) do if (f(v)) then res[#res+1] = v end end return res end -- Bl