[racket] Help: Running racket programs from command line

From: A Z (ukbc57 at gmail.com)
Date: Tue Sep 28 20:27:25 EDT 2010

Hello,

Can anyone please tell me how to process all the files in a directory.

This is what I am doing:

(check-progs (directory-list "/home/racket/progs"))

(define (check-progs flist)
  (if(list? flist)
     (if(null? (cdr flist))
        '()
        (check-progs (cdr flist)))
     (process (simple-form-path (car flist)))))


(define (process path)
  (local-require path)
  (local-require rackunit)
  (check-equal? (twice 2) 4)

Thanks in advance.
Colum

On Tue, Sep 28, 2010 at 5:13 PM, Deren Dohoda <deren.dohoda at gmail.com>wrote:

> Colum, what you're looking for, I believe, is local-require.
>
> On Tue, Sep 28, 2010 at 5:07 PM, A Z <ukbc57 at gmail.com> wrote:
> > Hello,
> >
> > There is a problem. 'require' does not go inside the definition of a
> > function. DrRacket complains that it needs to go in a module.
> >
> > I need (require path) inside a function because I want to run functions
> from
> > each .rkt file in a directory. I can write (require "file.rkt") for each
> of
> > the file at the top, but that does not look good.
> >
> > Thanks everyone.
> > Colum
> >
> >
> > On Tue, Sep 28, 2010 at 12:32 AM, John Clements <
> clements at brinckerhoff.org>
> > wrote:
> >>
> >> On Sep 27, 2010, at 3:35 PM, A Z wrote:
> >>
> >> > Hello Horace,
> >> >
> >> > I thank you for patiently explaining me how to run racket from command
> >> > line.
> >> >
> >> > Actually, this is not exactly what I am looking for.
> >> >
> >> > What I want is a script file. Such that I can test the modules of the
> >> > program from command prompt.
> >> >
> >> > Something like
> >> >
> >> > *******
> >> > #!/bin/bash
> >> > racket -f "file.rkt"
> >> >
> >> > racket (twice 2)
> >> > *******
> >>
> >> Ah! Caught.
> >>
> >> Okay, you want a file that tests another file.  The easy way to do this
> is
> >> not to dip into shell programming at all, but to write your script as
> >> another racket program.  For the example you provide:
> >>
> >> ****
> >> #lang racket
> >>
> >> (require "file.rkt")
> >> (require rackunit)
> >>
> >> (check-equal? (twice 2) 4)
> >> *****
> >>
> >>
> >> Then just run this file from the command-line.  If it were called
> >> 'tests.rkt', you could run it as
> >>
> >> racket tests.rkt
> >>
> >>
> >>
> >> John Clements
> >>
> >
> >
> > _________________________________________________
> >  For list-related administrative tasks:
> >  http://lists.racket-lang.org/listinfo/users
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20100928/86e28c08/attachment.html>

Posted on the users mailing list.