[racket] testing impure stuff

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Mon Dec 23 00:42:48 EST 2013

It can require significant refactoring to separate out the filesystem uses
and so you may consider it too painful, but it really does make for better
code and you don't have to deal with the filesystem anywhere near as much.

Robby



On Sun, Dec 22, 2013 at 10:19 PM, Manfred Lotz <manfred.lotz at arcor.de>wrote:

> On Sun, 22 Dec 2013 14:52:55 -0600
> Robby Findler <robby at eecs.northwestern.edu>
> wrote:
>
> > You should also consider structuring your code such that the code that
> > actually touches the filesystem is separate from the logic that does
> > whatever your program does. Then you can plug in a "fake" filesystem
> > that just implements the same api as the real code, but that also
> > does some specific, small thing for the purpose of testing.
> >
> > Robby
> >
>
> There is only one function which isn't file system specific, and which
> is already included in the test module. I just realized that it is
> anyway difficult to test via rackunit because the command line switches
> cannot be easily simulated.
>
> It seems that it is best to create the appropriate directory/file
> structure via script, and call rdupes via script in different
> ways. Then I can compare the output with a model output.
>
>
>
> --
> Manfred
>
>
> >
> > On Sun, Dec 22, 2013 at 1:28 PM, Manfred Lotz
> > <manfred.lotz at arcor.de> wrote:
> >
> > > On Sun, 22 Dec 2013 14:04:40 -0500
> > > Matthias Felleisen
> > > <matthias at ccs.neu.edu> wrote:
> > >
> > > >
> > > > On Dec 22, 2013, at 1:54 PM, Manfred Lotz wrote:
> > > >
> > > > > Hi there,
> > > > > I just wrote a file duplicate finder where I'm not quite sure
> > > > > how to build up my test cases.
> > > > >
> > > > > The problem is that most of my test cases are impure. They rely
> > > > > upon a directory layout.
> > > > >
> > > > > What is the best way to do this? Should I create a directory
> > > > > structure containing most (or better all) of my test cases, and
> > > > > then base my test cases upon the existing structure?
> > > > >
> > > > > Or perhaps even better create my directory structure on the fly
> > > > > and build my test cases upon this?
> > > > >
> > > > >
> > > > > How do other people create test cases for impure situations?
> > > >
> > > >
> > > > I have written such a program several years ago (a primitive
> > > > version) and I tested it by writing another program that
> > > > generated tmp directories with certain characteristics. --
> > > > Matthias
> > > >
> > >
> > >
> > > Ok, this convinces me to create a directory tree structure on the
> > > fly (containing all cases I need), and then base my test cases on
> > > the created tree structure.
> > >
> > >
> > > --
> > > Thanks,
> > > Manfred
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > >
> > > ____________________
> > >   Racket Users list:
> > >   http://lists.racket-lang.org/users
> > >
> >
>
>
> ____________________
>   Racket Users list:
>   http://lists.racket-lang.org/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20131222/0e317e36/attachment.html>

Posted on the users mailing list.