Skip to content
Back to formatted view

Raw Message

Message-ID: <CALEXWq2mrzD=ZSY_MYAG+FgOMoPxAJ7HBFYvoQpbSbqFRaP_KQ@mail.gmail.com>
Date: 2017-12-12T13:17:23Z
From: IƱaki Ucar
Subject: [R-pkg-devel] creating indelible file during unit test
In-Reply-To: <CAJuCY5wTrLE5GRKFE-_LYgTE7Mx23tfoV_OPxk6cYn_6SXV=TQ@mail.gmail.com>

2017-12-12 13:24 GMT+01:00 Thierry Onkelinx <thierry.onkelinx at inbo.be>:
> Dear all,
>
> Some function I wrote deletes a bunch of files. It is crucial that all
> files get deleted. Hence it should return an error when one or more
> files couldn't be deleted.
>
> I'm writing a unit test for this function. I fail to create a file
> that can't be deleted by the function. I've tried Sys.chmod(file,
> "000") which didn't work.
>
> Any suggestions?

Supposing you call file.remove at some point, what about the following:

file.remove <- function(...) { invisible() }
# test your function here, should issue an error
rm("file.remove")

I?aki