2Running Delirium

Delirium can be started from a top-level application or from within a servlet.

2.1Running Delirium as a top-level application

(serve/delirium

start

test

[

#:run-tests?run-tests?

#:run-testsrun-tests

#:managermanager

#:portport

#:listen-iplisten-up

#:servlet-pathservlet-path

#:servlet-regexpservlet-regexp

#:extra-files-pathsextra-files-paths

#:mime-types-pathmime-types-path

#:launch-browser?launch-browser?

#:file-not-found-responderfile-not-found-responder])

→void?

start:(->request?response?)

test:schemeunit-test?

run-tests?:boolean?=#t

run-tests

:

(schemeunit-test?->any)

=

test/text-ui/pause-on-fail

manager:(Umanager?#f)=#f

port:natural?=8765

listen-up:(Ustring?#f)="127.0.0.1"

servlet-path:(Ustring?#f)="/"

servlet-regexp:(Ustring?#f)=#rx""

extra-files-paths:(listofpath?)=null

mime-types-path:(Upath?#f)=#f

launch-browser?:boolean?=#t

file-not-found-responder:(U(request?->response?)#f)=#f

Wrapper for serve/servlet that sets up sensible defaults for Delirium. All relevant arguments are passed straight through except the following:

if run-tests? is #t, start is wrapped using (make-delirium-controllerstarttestrun-tests);

if run-tests? is #t, "/test" is passed on as the value of servlet-path;

if manager, mime-types-path or file-not-found-responder is #fit reverts to its default value in serve/servlet.

2.2Running Delirium from within a servlet

(make-delirium-controller

application-controller

test

[

run-tests])

→(request?->response?)

application-controller:(request?->response?)

test:schemeunit-test?

run-tests:procedure?=test/text-ui/pause-on-fail

Wraps application-controller, creating a controller procedure that runs the Delirium test suite if the URL begins with "/test". All other URLs are passed through to the application.

(run-deliriumrequesttest[run-tests])→response?

request:request?

test:schemeunit-test?

run-tests:procedure?=test/text-ui/pause-on-fail

Sends the Delirium test page to the browser and starts running the given test case (which can be a SchemeUnit test suite or test case).

The optional run-tests argument specifies a function to actually run the tests. The default value of run-tests is a version of Schemeunit.plt’s test/text-ui procedure that pauses after each failed test and asks if you wish to continue running tests. This is useful because it allows you to inspect the state of the web page at the point of failure to see what went wrong.