tests/push.job.re.run.test.R

require(qrmarkdown)
require(testthat)

cleanlog <- function()
{
  if(file.exists('testlog'))
    system('rm -r testlog')

  q.wd('testlog')
  dir('testlog')
}

# Let, rerun test
#
require(qrmarkdown)
cleanlog()

# Create Rmarkdown report has error
RCode <- "stop (' Rmark down exception!!! ') "

# create rmarkdown test throw execption
jid <- q.push(name='test rmarkdown failer 1', code=RCode)
res <- q.ls(jid)

expect(res$status == q.status$waiting, "before run job queue check")

# run a file with error
jid <- q.run(jid = jid)

# error type of passing data.frame ticket
expect_error(q.ls(jid = jid))

res <- q.ls(jid = jid$jid)

expect(res$status == q.status$failed, "did we catch expection error test ")

# did we catch correct error?
expect((grep('Rmark down exception', res$log) == 1) , "did we catch expection error test ")

# rerun is the feature to push it back to job queue so
# this needs to be tagged as 'inbox' waiting queue.

message( 'q.validation is new way to re-run failed process in queue')
cleanlog()

fail.id1 <- q.push(name='test rmarkdown failer 1', code=RCode)
fail.id1 <- q.run(fail.id1)

fail.id2 <- q.push(name='test rmarkdown failer 2', code=RCode)
fail.id2 <- q.run(fail.id2)

result <- q.show()

expect(result$failed == 2, "failed test count check ")

# This scan failed test automatically, rerun with queue.
debug(q.dispatcher)

# TODO: Validate later
q.dispatcher(n=2,timer = 4)
q.validation()

result <- q.show()
expect(result$failed == 2, "failed test count check ")
okux/qrmarkdown documentation built on Dec. 22, 2021, 4:17 a.m.