Nothing
# M118 -- the three name-resolution skip helpers, and the two hardware-probe
# ones, must skip on CRAN's own submission check and nowhere else.
#
# The assertion is on WHICH skip, never on a bare one: a helper whose binary is
# absent also skips, and reading that as the CRAN skip would pass this file on a
# machine where NOT_CRAN never mattered. testthat::skip() signals a condition of
# class "skip" carrying "Reason: <message>" (measured 2026-09-08), so the reason
# string is what separates the two.
#
# Two ways of saying "on CRAN" are asked, because testthat has two branches
# (`testthat:::on_cran()`, 3.3.2): NOT_CRAN="false" goes through as.logical() and
# means CRAN in any session, while an unset NOT_CRAN means !interactive() -- so
# from a console an unset variable says NOT on CRAN, and only the "false" form
# can be asserted unconditionally.
# Run `helper` with NOT_CRAN in the given state and return the skip reason, or
# NA_character_ when it did not skip. `value = NA` unsets the variable.
tm_skip_reason <- function(helper, not_cran) {
withr::with_envvar(c(NOT_CRAN = not_cran), {
tryCatch(
{
helper()
NA_character_
},
skip = function(cnd) conditionMessage(cnd)
)
})
}
cran_helpers <- list(
skip_if_no_ffmpeg = skip_if_no_ffmpeg,
skip_if_no_ffprobe = skip_if_no_ffprobe,
skip_if_no_mediainfo = skip_if_no_mediainfo,
skip_if_no_nvenc = skip_if_no_nvenc,
skip_if_no_videotoolbox = skip_if_no_videotoolbox,
# Not a binary helper: it guards the combinatorial sweeps, which spawn
# nothing and are skipped on CRAN for their cost. Held to the same CRAN bar
# as the rest, and to its own control below, since the binary map cannot
# carry it.
skip_sweep_on_cran = skip_sweep_on_cran
)
test_that("each skip helper skips FOR CRAN when NOT_CRAN says CRAN", {
for (name in names(cran_helpers)) {
reason <- tm_skip_reason(cran_helpers[[name]], "false")
expect_match(
reason, "On CRAN",
info = paste0(name, " did not skip for CRAN with NOT_CRAN=false")
)
}
})
test_that("an unset NOT_CRAN means CRAN in the session CRAN checks in", {
# CRAN's own check is never interactive, so this is the condition that ships.
# From a console the same call correctly does not skip, which is why this is
# asked in its own block rather than folded into the one above.
skip_if(interactive(), "an unset NOT_CRAN means CRAN only when non-interactive")
for (name in names(cran_helpers)) {
reason <- tm_skip_reason(cran_helpers[[name]], NA)
expect_match(
reason, "On CRAN",
info = paste0(name, " did not skip for CRAN with NOT_CRAN unset")
)
}
})
test_that("NOT_CRAN=true lifts the CRAN skip from the three name helpers", {
# The control half. Without it an "On CRAN" match above would also pass for a
# helper that skips unconditionally. Only meaningful where the binary is on
# PATH, so each program is asked separately rather than gating the whole test.
programs <- c(
skip_if_no_ffmpeg = "ffmpeg",
skip_if_no_ffprobe = "ffprobe",
skip_if_no_mediainfo = "mediainfo"
)
present <- programs[nzchar(Sys.which(programs))]
skip_if(
length(present) == 0L,
"none of ffmpeg, ffprobe or mediainfo is on PATH"
)
for (name in names(present)) {
expect_identical(
tm_skip_reason(cran_helpers[[name]], "true"), NA_character_,
info = paste0(name, " still skipped with NOT_CRAN=true and the binary on PATH")
)
}
})
test_that("NOT_CRAN=true lifts the CRAN skip from the sweep helper", {
# The sweep helper's own control. It asks no binary question, so it is not in
# the map above and needs no PATH gate: off CRAN it must not skip at all,
# which is what keeps the three sweeps running on every other runner.
expect_identical(
tm_skip_reason(skip_sweep_on_cran, "true"), NA_character_,
info = "skip_sweep_on_cran() skipped with NOT_CRAN=true"
)
})
test_that("the CRAN skip comes before the binary question", {
# Both conditions hold at once -- on CRAN, and no binary reachable. The helper
# must report CRAN, which is only true if skip_on_cran() runs first. PATH = ""
# is how helper-program-config.R:43 makes a program unreachable. NOT_CRAN is
# given as "false" so the ordering question is asked in either session kind.
withr::with_envvar(c(PATH = ""), {
for (name in names(cran_helpers)) {
expect_match(
tm_skip_reason(cran_helpers[[name]], "false"), "On CRAN",
info = paste0(name, " reported the binary, not CRAN, when both applied")
)
}
})
})
Any scripts or data that you put into this service are public.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.