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