| 1 |
library(testit) |
| 2 |
|
| 3 |
assert('clean_log() removes OK lines, current time, and other noise', { |
| 4 |
d = tempfile(); dir.create(d) |
| 5 |
owd = setwd(d); on.exit({ setwd(owd); unlink(d, recursive = TRUE) }, add = TRUE) |
| 6 |
|
| 7 |
writeLines(c( |
| 8 |
'log dir line', |
| 9 |
'R version line', |
| 10 |
'* using R version 4.4.0 ... OK', |
| 11 |
'* current time: 2026-07-07 14:49:46 UTC', |
| 12 |
'* checking foo ... WARNING', |
| 13 |
'some detail' |
| 14 |
), '00check.log') |
| 15 |
|
| 16 |
x = clean_log() |
| 17 |
# first 2 lines removed, OK line removed, current time line removed |
| 18 |
(!any(grepl('OK$', x))) |
| 19 |
(!any(grepl('current time', x))) |
| 20 |
(x %==% c('* checking foo ... WARNING', 'some detail')) |
| 21 |
}) |