lib/nitcorn: skip the listening loop when running continuous integration tests
authorAlexis Laferrière <alexis.laf@xymus.net>
Wed, 6 Jan 2016 18:54:46 +0000 (13:54 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Wed, 6 Jan 2016 20:34:17 +0000 (15:34 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/nitcorn/reactor.nit

index 5bd285d..0fb5cad 100644 (file)
@@ -133,10 +133,18 @@ class HttpFactory
 
        redef fun spawn_connection(buf_ev) do return new HttpServer(buf_ev, self)
 
-       # Launch the main loop of this server
+       # Execute the main listening loop to accept connections
+       #
+       # After the loop ends, the underlying resources are freed.
+       #
+       # When the environment variable `NIT_TESTING` is set to `true`,
+       # the loop is not executed but the resources are still freed.
        fun run
        do
-               event_base.dispatch
+               if "NIT_TESTING".environ != "true" then
+                       event_base.dispatch
+               end
+
                event_base.destroy
        end
 end