[racket] Order of executing required modules

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Apr 5 11:21:06 EDT 2011

FWIW, you also have to make sure that any module that requires your
test module does not also require one of the sub test modules as that
could also mess up the order (but I'm sure that you don't in this

What I generally do in a situation like this (where I have a bunch of
test files like you do) is to use dynamic-require, eg:

(define test-modules '("a.rkt" "b.rkt")) ;; etc
(for ((x (in-list test-modules)))
  (printf "running tests in ~a\n" x)
  (dynamic-require x #f))

and perhaps even catch exceptions to continue running tests if some of
them fail.

But dynamic-require doesn't transmit its dependency information to the
compiler, so building an executable would have to be told explicitly
which files to include to make those dynamic-requires work.


On Tue, Apr 5, 2011 at 10:17 AM, Jos Koot <jos.koot at telefonica.net> wrote:
> That's clear. My test modules do not require any other test module and
> export nothing.
> Lesson learned: modules that are required by other ones should not produce
> side effects that may alter the behaviour of another required module. Well,
> I never did so, but it is good to be aware of it. I expect that the top
> level module of a program may rely on side effects of sub level modules (as
> for example in a module defining a new language and read-table for a module
> using this language)
> Thanks, Jos
>> -----Original Message-----
>> From: robby.findler at gmail.com
>> [mailto:robby.findler at gmail.com] On Behalf Of Robby Findler
>> Sent: 05 April 2011 16:57
>> To: Jos Koot
>> Cc: users
>> Subject: Re: [racket] Order of executing required modules
>> I don't think that there is any particular reason for that specific
>> order, but there is a reason not to rely on any order. Specifically,
>> if you ever get one of those other files requiring each other, then
>> this will disrupt the order you see. For example, if both test-a.rkt
>> and test-z.rkt require test-l.rkt, then test-l.rkt will run before
>> either of them.
>> Robby
>> On Tue, Apr 5, 2011 at 9:49 AM, Jos Koot
>> <jos.koot at telefonica.net> wrote:
>> > Hi
>> > Consider:
>> >
>> > File all-tetst.rkt
>> > #lang scheme
>> > (require "test-a.rkt")
>> > (require "test-b.rkt")
>> > (require "test-c.rkt")
>> > (require "test-d.rkt")
>> > ...
>> > (require "test-z.rkt")
>> >
>> > It appears that the tests are done in reverse order, id est
>> from z to a in
>> > stead from a to z. Not really a problem for me, but it
>> could be for modules
>> > that produce side effects (for example, one writing a file,
>> the other one
>> > reading it) I wonder: is there a specific reason for the reversed
>> > invokations of the required modules? Or should I use
>> another manner for
>> > running the tests in a specific order?
>> >
>> > Thanks, Jos
>> >
>> > _________________________________________________
>> >  For list-related administrative tasks:
>> >  http://lists.racket-lang.org/listinfo/users
>> >

Posted on the users mailing list.