[racket] testing impure stuff
On Sun, Dec 22, 2013 at 2:49 PM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> Manfred Lotz wrote at 12/22/2013 01:54 PM:
>> Or perhaps even better create my directory structure on the fly and
>> build my test cases upon this?
> Yes, like that. It can be tedious to develop, but then your test suite is
> more likely to work when you or someone else needs it to.
I agree. Even if you use a file system mock, it's better to test on
real file systems, too. You're more likely to encounter real-world
situations you need to handle in your code -- and in your file system
mock.
For instance running `fold-files` on certain paths will likely give
you some items for which you lack permissions. Either you need to
distinguish them using `file-or-directory-permissions` and not try to
read them at all, or, use `with-handlers` to catch the resulting
exceptions.
That's an example of something you might not think to include in a
file system mock, at least not until you've encountered it in a real
file system.