[racket-dev] Testing mode

From: Jay McCarthy (jay.mccarthy at gmail.com)
Date: Mon Jun 27 20:03:46 EDT 2011

We've talked before about having a testing mode so that tests could be
written inline, but not run when the module is normally run. I've
attached a patch that adds a simple way of doing this.

racket/test gives you
- with-testing
- with-deploying

The first is a block of testing code. The second is a block of deployment code.

The first never runs normally, but only runs when testing. The second
always runs normally, but never runs during testing. (The second is to
do stuff like parsing command line arguments or opening GUI windows,
Web servers, etc.)

I would expect that some would want Rackunit to always wrap its tests
in testing mode, but I didn't include that.

It also adds "raco test" which runs a file in testing mode. You can
optionally add the "--all" option so that all dynamically required
modules are run in testing mode as well. There could also be a testing
button in DrRacket, but I didn't include that.

I think this is nice and a bare minimum that solves the problem. Any thoughts?


Here's a little interaction:

% racket c.rkt
c running!
% racket b.rkt
c running!
b running!
% racket a.rkt
c running!
b running!
a running!
% raco test a.rkt
1 test passed
% raco test --all a.rkt
1 test passed
1 test passed
1 test passed

Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University

"The glory of God is Intelligence" - D&C 93
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Adding-a-simple-testing-mode-library.patch
Type: application/octet-stream
Size: 5422 bytes
Desc: not available
URL: <http://lists.racket-lang.org/dev/archive/attachments/20110627/344c1ede/attachment.obj>

Posted on the dev mailing list.