tests/testthat/test-examples.R

# library(testthat); devtools::load_all(); 
context("Example stages")
files = c("code.R", "remake.yml", "Makefile")

test_that("Stages in basic example happen correctly.", {
  testwd("examples")
  expect_warning(expect_error(write_makefile()))
  example = "basic"
  expect_silent(example_parallelRemake(example))
  expect_error(example_parallelRemake(example))
  expect_error(example_parallelRemake("asldasdflkklsdfjlkfjaljsdfpiojallksdkf"))
  setwd(example)
  for(f in c("code.R", "remake.yml")) expect_true(f %in% list.files())
  makefile("random", remake_args = list(verbose = F))
  expect_equal(recallable(), "random")
  expect_false(file.exists("plot.pdf"))
  makefile(remake_args = list(verbose = F), command = "make", args = "-j2")
  expect_true(file.exists("plot.pdf"))
  file.copy("../../test-examples/code.R", "code.R", overwrite = TRUE)
  makefile(remake_args = list(verbose = F), run = F)
  x = system2("make", stdout = T)
  expect_true(any(grepl(timestamp("plot.pdf"), x)))
  makefile(remake_args = list(verbose = F), run = F)
  x = system2("make", stdout = T)
  expect_equal(length(x), 1)
  expect_true(grepl( "Nothing to be done", x))
  setwd("..")
  unlink(example, recursive = TRUE)
  testrm("examples")
})
wlandau/parallelRemake documentation built on May 4, 2019, 8:44 a.m.