((section 2 "Outdated egg!" (p "This is an egg for CHICKEN 4, the unsupported old release.  You're almost certainly looking for " (int-link "/eggref/5/server-test" "the CHICKEN 5 version of this egg") ", if it exists.") (p "If it does not exist, there may be equivalent functionality provided by another egg; have a look at the " (link "https://wiki.call-cc.org/chicken-projects/egg-index-5.html" "egg index") ". Otherwise, please consider porting this egg to the current version of CHICKEN.")) (section 2 "server-test" (toc) (section 3 "Description" (p "Utilities to help testing servers")) (section 3 "Author" (p (int-link "/users/mario-domenech-goulart" "Mario Domenech Goulart"))) (section 3 "Repository" (p (link "https://github.com/mario-goulart/server-test" "https://github.com/mario-goulart/server-test"))) (section 3 "Parameters" (section 4 "test-server-port" (def (sig (parameter "(test-server-port [integer])" (id test-server-port))) (p "The port to access the test server.  The default value is " (tt "8080") "."))) (section 4 "connect-procedure" (def (sig (parameter "(connect-procedure [procedure])" (id connect-procedure))) (p "The procedure to be used to check if the server is ready to accept requests.  Default is " (tt "tcp-connect") " from " (int-link "/man/4/Unit tcp" "unit tcp") "."))) (section 4 "standby-time" (def (sig (parameter "(standby-time [integer])" (id standby-time))) (p "Time in seconds to wait for the server to start serving after it has started accepting connections.  This parameter was introduced in version 0.4."))) (section 4 "max-attempts-to-connect" (def (sig (parameter "(max-attempts-to-connect [integer])" (id max-attempts-to-connect))) (p "Maximum number of attempts to connect to the server before assuming that it failed to start. This parameter was introduced in version 0.4."))) (section 4 "time-between-attempts-to-connect" (def (sig (parameter "(time-between-attempts-to-connect [integer])" (id time-between-attempts-to-connect))) (p "Time in seconds to wait between to consecutive attempts to connect to the server. This parameter was introduced in version 0.4.")))) (section 3 "Procedures" (section 4 "High level interface" (section 5 "with-test-server" (def (sig (procedure "(with-test-server server-thunk tests-thunk)" (id with-test-server))) (p "Start the server by executing " (tt "server-thunk") ", run the tests (" (tt "tests-thunk") ") and stop the server.") (p "Here's a usage example with the " (int-link "/egg/awful" "awful") ", " (int-link "/egg/test" "test") " and " (int-link "/egg/http-client" "http-client") " eggs:") (p "The awful application to be tested:") (highlight scheme "(use awful)\n\n(define-page \"/foo\"\n  (lambda ()\n    \"foo\")\n  no-template: #t)") (p "The test program:") (highlight scheme "(use server-test awful http-client test)\n\n;; The awful application to be tested\n(awful-apps (list \"foo.scm\"))\n\n(with-test-server\n (lambda ()\n   (awful-start\n    (lambda ()\n      (load-apps (awful-apps)))))\n (lambda ()   \n   (test \"foo\"\n         (with-input-from-request \"http://localhost:8080/foo\"\n                                  #f\n                                  read-string))))")))) (section 4 "Low level interface" (section 5 "start-test-server" (def (sig (procedure "(start-test-server thunk)" (id start-test-server))) (p "Start the test server and returns its pid.  " (tt "thunk") " is the procedure which actually runs the server."))) (section 5 "stop-test-server" (def (sig (procedure "(stop-server pid)" (id stop-server))) (p "Stops the server whose pid is the given " (tt "pid") "."))))) (section 3 "License" (pre "Copyright (c) 2012-2018 Mario Domenech Goulart\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are\nmet:\n\nRedistributions of source code must retain the above copyright\nnotice, this list of conditions and the following disclaimer.\n\nRedistributions in binary form must reproduce the above copyright\nnotice, this list of conditions and the following disclaimer in the\ndocumentation and/or other materials provided with the distribution.\n\nNeither the name of the author nor the names of its contributors may\nbe used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n\"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\nLIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS\nFOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE\nCOPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,\nINDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR\nSERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)\nHOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,\nSTRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\nARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED\nOF THE POSSIBILITY OF SUCH DAMAGE.")) (section 3 "Version history" (section 5 "version 0.6" (ul (li "CHICKEN 5 support"))) (section 5 "version 0.5" (ul (li "Bug fix: propagate exceptions raised when running tests code"))) (section 5 "version 0.4" (ul (li "Add " (tt "standby-time") ", " (tt "max-attempts-to-connect") " and " (tt "time-between-attempts-to-connect") " parameters"))) (section 5 "version 0.3" (ul (li "Fixed release numbers/tags (thanks to Peter Bex)"))) (section 5 "version 0.2" (ul (li "Bug fix in the internal " (tt "can-connect?") " procedure (it was not honoring " (tt "test-server-port") ")"))) (section 5 "version 0.1" (ul (li "Initial release"))))))