[racket-dev] Testing mode
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?
Jay
Here's a little interaction:
~plt/collects/tests/racket/testing
% racket c.rkt
c running!
~plt/collects/tests/racket/testing
% racket b.rkt
c running!
b running!
~plt/collects/tests/racket/testing
% racket a.rkt
c running!
b running!
a running!
~plt/collects/tests/racket/testing
% raco test a.rkt
1 test passed
~plt/collects/tests/racket/testing
% raco test --all a.rkt
1 test passed
1 test passed
1 test passed
~plt/collects/tests/racket/testing
%
--
Jay McCarthy <jay at cs.byu.edu>
Assistant Professor / Brigham Young University
http://faculty.cs.byu.edu/~jay
"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>