mikldk / roxytest

Inline testthat tests with roxygen2
95 stars 3 forks source link

Don't work with \donttest tag #12

Closed ShixiangWang closed 4 years ago

ShixiangWang commented 4 years ago

Thanks for your tool.

Is it possible to rm \donttest{} in @examples or just remove all codes in \donttest in testthat? The same situation may be applied to \dontrun


context("File R/show_sig_number_survey.R: @testexamples")

test_that("Function show_sig_number_survey() @ L60", {

  \donttest{
  # Load copy number prepare object
  load(system.file("extdata", "toy_copynumber_tally_M.RData",
    package = "sigminer", mustWork = TRUE
  ))
  library(NMF)
  cn_estimate <- sig_estimate(cn_tally_M$nmf_matrix,
    cores = 1, nrun = 5,
    verbose = TRUE
  )

  # Show two measures
  show_sig_number_survey(cn_estimate)
  # Show one measure
  show_sig_number_survey(cn_estimate, right_y = NULL)

  # Show data from a data.frame
  show_sig_number_survey(cn_estimate$survey)
  # Show other measures
  head(cn_estimate$survey)
  show_sig_number_survey(cn_estimate$survey,
    right_y = "dispersion",
    right_name = "dispersion"
  )
  show_sig_number_survey(cn_estimate$survey,
    right_y = "evar",
    right_name = "evar"
  )
  }
  expect_equal(length(cn_estimate), 2)
})
mikldk commented 4 years ago

Thanks! I will look into it.

mikldk commented 4 years ago

Can you see if it is now fixed by 74b3c9b501b045fef56e294c3111932a7062726f?

ShixiangWang commented 4 years ago

@mikldk Sorry for forgetting to read this message.

ShixiangWang commented 4 years ago

This doesn't work if there are if-else block in the \donttest or \dontrun. And I have question about it, hope we can discuss it. Typically I use \donttest in @examples to ignore the operation which may take long time, and \dontrun to operation may cause error. Therefore, should remove just \donttest{} and keep its content?

mikldk commented 4 years ago

Can you test if it works now with 8bfe1663632fb96f89113250d981dec3d8833002?

ShixiangWang commented 4 years ago

@mikldk Yeah, it works in if-else block now, thanks for you quick fix. I want to remove donttest{} tag in examples so the content can be tested, is it possible?

mikldk commented 4 years ago

That should happen now? Everything in \donttest{} and \dontrun{} should be deleted. Is it not? See e.g. this test.

ShixiangWang commented 4 years ago

@mikldk Yeah, they will be deleted. However, in my personal practice, I think

mikldk commented 4 years ago

@ShixiangWang Ahh, now I understand. Please give c1ef1f7 a go.

ShixiangWang commented 4 years ago

@mikldk Thanks, it works :).