| 1 |
## Look for detritus files |
| 2 |
testme <- as.environment("testme") |
| 3 |
if (isTRUE(debug)) message(sprintf("Looking for detritus files generated by test %s:", sQuote(testme[["name"]]))) |
| 4 |
path <- dirname(tempdir()) |
| 5 |
|
| 6 |
if (basename(path) == "working_dir") { |
| 7 |
files <- dir(pattern = "^Rscript", path = path, all.files = TRUE, full.names = TRUE) |
| 8 |
message(sprintf("Detritus 'Rscript*' files: [n=%d]", length(files))) |
| 9 |
print(files) |
| 10 |
|
| 11 |
if (length(files) > 0L) { |
| 12 |
## Remove detritus files produced by this test script, so that |
| 13 |
## other test scripts will not fail because of these files. |
| 14 |
unlink(files) |
| 15 |
|
| 16 |
msg <- sprintf("Detected 'Rscript*' files: [n=%d] %s", length(files), paste(sQuote(basename(files)), collapse = ", ")) |
| 17 |
|
| 18 |
## Are detritus files files expected by design on MS Windows? |
| 19 |
## If so, produce a warning, otherwise an error |
| 20 |
if ("detritus-files" %in% testme[["tags"]] && |
| 21 |
.Platform[["OS.type"]] == "windows") { |
| 22 |
warning(msg, immediate. = TRUE) |
| 23 |
} else { |
| 24 |
stop(msg) |
| 25 |
} |
| 26 |
} |
| 27 |
} else { |
| 28 |
if (isTRUE(debug)) message(sprintf("Skipping, because path appears not to be an 'R CMD check' folder: %s", sQuote(path))) |
| 29 |
} |