[racket-dev] wishes

From: Eli Barzilay (eli at barzilay.org)
Date: Fri May 6 11:57:16 EDT 2011

Three minutes ago, Vincent St-Amour wrote:
> At Fri, 6 May 2011 11:22:48 -0400,
> Matthias Felleisen wrote:
> > 1. Python seems to provide the following unit testing
> >    functionality:
> > 
> >    if a file/module is run as 'main', the test suites are run; if
> >    it is required into some other file, the tests aren't run.
> > 
> >    It looks truly convenient. I believe we should be able to write
> >    a define-test-suite macro that can do that too.

I wanted something like that for the same reason...


> Along these lines, a "raco test" command that runs the tests for a
> file, without running the program itself, would be great.

... but I don't think there's any need for this (especially since the
same is useful in other situations too).  The setup that I think works
best is -- make each file provide a `run' (or whatever):

   #lang racket
   (provide run)
   (define (run) ...stuff...)

And to combine test suits you do the obvious thing:

  #lang racket
  (require (prefix-in a: "a.rkt")
           (prefix-in b: "b.rkt"))
  (define (run) (a:run) (b:run))

and now instead of a new raco command, you "just" use racket with -e
"(run)".  But this does lead to a justification for some new command
since getting it to run can be a little tricky:

  racket -lue racket/base x "(run)"

so maybe have some raco command that does that.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!


Posted on the dev mailing list.