diff --git a/DESCRIPTION b/DESCRIPTION index 934684d..146aa85 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -26,7 +26,7 @@ Depends: R (>= 4.0) Imports: htmlwidgets (>= 0.3.2), - rlang (>= 0.4.9), + rlang (>= 1.1.0), vctrs Suggests: htmltools, diff --git a/R/profvis.R b/R/profvis.R index 423cd68..2b0f5aa 100644 --- a/R/profvis.R +++ b/R/profvis.R @@ -102,15 +102,11 @@ profvis <- function(expr = NULL, torture = 0, simplify = TRUE, rerun = FALSE) { + check_exclusive(expr, prof_input) split <- match.arg(split) c(expr_q, env) %<-% enquo0_list(expr) - if (is.null(prof_input) && is.null(expr_q)) { - stop("profvis must be called with `expr` or `prof_input` ") - } - if (!is.null(prof_input) && (!is.null(expr_q) && !is.null(prof_output))) { - stop("The `prof_input` argument cannot be used with `expr` or `prof_output`.") - } + if (interval < 0.005) { message("Intervals smaller than ~5ms will probably not result in accurate timings.") } diff --git a/tests/testthat/_snaps/profvis.md b/tests/testthat/_snaps/profvis.md new file mode 100644 index 0000000..ac96489 --- /dev/null +++ b/tests/testthat/_snaps/profvis.md @@ -0,0 +1,8 @@ +# expr and prof_input are mutually exclusive + + Code + profvis(expr = f(), prof_input = "foo.R") + Condition + Error in `profvis()`: + ! Exactly one of `expr` or `prof_input` must be supplied. + diff --git a/tests/testthat/test-profvis.R b/tests/testthat/test-profvis.R index 3120170..bf48ef8 100644 --- a/tests/testthat/test-profvis.R +++ b/tests/testthat/test-profvis.R @@ -24,3 +24,7 @@ test_that("defaults to elapsed timing", { out <- repro_profvis(f(), rerun = "Sys.sleep") expect_equal(profile_mode(out), "Sys.sleep f") }) + +test_that("expr and prof_input are mutually exclusive", { + expect_snapshot(profvis(expr = f(), prof_input = "foo.R"), error = TRUE) +})