mllg / checkmate

Fast and versatile argument checks
https://mllg.github.io/checkmate/
Other
261 stars 30 forks source link

assert_file_exists fails with complex extension #195

Closed artemklevtsov closed 3 years ago

artemklevtsov commented 4 years ago

Seems assert_file_exists don't recognize correct extensions like csv.gz.

Steps to reproduce:

x <- tempfile(fileext = ".csv.gz")
# "/tmp/RtmpVfYkVJ/file3aafe5eafe385.csv.gz"
write("", x)
assert_file_exists(x, extension = "csv.gz")
Error: Assertion on 'x' failed: File extension must be in {'csv.gz'}.

Reason is regex in the checkFileExtension which keep only last matched pattern.

> checkmate:::checkFileExtension("test.csv.gz", "csv.gz")
[1] "File extension must be in {'csv.gz'}"
> checkmate:::checkFileExtension("test.csv.gz", "gz")
[1] TRUE
mllg commented 3 years ago

Thanks for reporting, fixed now in master.