inst/testme/_epilogue/999.detritus.R

## Look for detritus files
testme <- as.environment("testme")
message(sprintf("Looking for detritus files generated by test %s:", sQuote(testme[["name"]])))
path <- dirname(tempdir())

if (basename(path) == "working_dir") {
  files <- dir(pattern = "^Rscript", path = path, all.files = TRUE, full.names = TRUE)
  message(sprintf("Detritus 'Rscript*' files: [n=%d]", length(files)))
  print(files)
  
  if (length(files) > 0L) {
    ## Remove detritus files produced by this test script, so that
    ## other test scripts will not fail because of these files.
    unlink(files)

    msg <- sprintf("Detected 'Rscript*' files: [n=%d] %s", length(files), paste(sQuote(basename(files)), collapse = ", "))

    ## Are detritus files files expected by design on MS Windows?
    ## If so, produce a warning, otherwise an error
    if ("detritus-files" %in% testme[["tags"]] &&
        .Platform[["OS.type"]] == "windows") {
      warning(msg, immediate. = TRUE)
    } else {
      stop(msg)
    }
  }
} else {
  message(sprintf("Skipping, because path appears not to be an 'R CMD check' folder: %s", sQuote(path)))
}

Try the parallelly package in your browser

Any scripts or data that you put into this service are public.

parallelly documentation built on April 4, 2025, 4:38 a.m.