Skip to content

Commit

Permalink
Modernise skip_on_cran() (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
hadley authored Jul 2, 2024
1 parent fa0b3c2 commit e035176
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
6 changes: 0 additions & 6 deletions tests/testthat/helper-profvis.R
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,3 @@ profvis_modal_value <- function(prof) {
stacks <- vapply(stacks, paste, "", collapse = " ")
modal_value0(stacks)
}

skip_on_cran_if_not_ci <- function() {
if (!is_true(as.logical(Sys.getenv("CI")))) {
skip_on_cran()
}
}
5 changes: 2 additions & 3 deletions tests/testthat/test-profvis.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

skip_on_cran_if_not_ci()

test_that("Irrelevant stack is trimmed from profiles (#123)", {
skip_on_cran()

f <- function() pause(TEST_PAUSE_TIME)

out <- repro_profvis(f(), simplify = FALSE)
Expand Down
7 changes: 5 additions & 2 deletions tests/testthat/test-rprof.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@

skip_on_cran_if_not_ci()

test_that("`rprof_lines()` collects profiles", {
skip_on_cran()
f <- function() pause(TEST_PAUSE_TIME)

out <- rprof_lines(f(), rerun = "pause")
Expand All @@ -11,6 +10,7 @@ test_that("`rprof_lines()` collects profiles", {
})

test_that("`filter.callframes` filters out intervening frames", {
skip_on_cran()
skip_if_not(has_simplify())

# Chains of calls are kept
Expand All @@ -25,6 +25,7 @@ test_that("`filter.callframes` filters out intervening frames", {
})

test_that("stack is correctly stripped even with metadata profiling", {
skip_on_cran()
f <- function() pause(TEST_PAUSE_TIME)
zap <- function(lines) modal_value0(zap_trailing_space(zap_srcref(zap_meta_data(lines))))

Expand All @@ -48,6 +49,7 @@ test_that("stack is correctly stripped even with metadata profiling", {
})

test_that("`pause()` does not include .Call() when `line.profiling` is set", {
skip_on_cran()
f <- function() pause(TEST_PAUSE_TIME)

# `pause()` should appear first on the line
Expand All @@ -56,6 +58,7 @@ test_that("`pause()` does not include .Call() when `line.profiling` is set", {
})

test_that("srcrefs do not prevent suffix replacement", {
skip_on_cran()
line <- ":1509169:3184799:91929040:0:\"pause\" 1#1 \"f\" \"doTryCatch\" \"tryCatchOne\" \"tryCatchList\" \"doTryCatch\" \"tryCatchOne\" \"tryCatchList\" \"tryCatch\" 2#193 \"with_profvis_handlers\" 2#151 \"profvis\" "
suffix <- "\"doTryCatch\" \"tryCatchOne\" \"tryCatchList\" \"doTryCatch\" \"tryCatchOne\" \"tryCatchList\" \"tryCatch\" 2#193 \"with_profvis_handlers\" 2#151 \"profvis\" $"
re <- gsub_srcref_as_wildcards(suffix)
Expand Down

0 comments on commit e035176

Please sign in to comment.