[racket] testing impure stuff

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Mon Dec 23 14:10:39 EST 2013

On Mon, 23 Dec 2013 13:53:05 -0500
Greg Hendershott
<greghendershott at gmail.com> wrote:

> 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.
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
> 

Yep, I also think it is best to create test directory structure and
take this for testing.

One question: How would I resume from a permission denied when using
in-directory.


Let's say I have this:

 
 (for ([f (in-directory  dir)] #:when (myfilter f))
      (do-something f))

Now I would like to report a permission denied error, and then
continue getting the next file.

I saw that there is 'with-handlers' or 'call-with-exception-handler'
but I did not find how to resume.


-- 
Manfred




Posted on the users mailing list.