diff options
author | Robert Brewer <fumanchu@aminus.org> | 2008-07-24 04:33:20 +0000 |
---|---|---|
committer | Robert Brewer <fumanchu@aminus.org> | 2008-07-24 04:33:20 +0000 |
commit | 35a64b2dce7571bab2e385f99bdb234c9793a219 (patch) | |
tree | ed6db0839fa7017c3f79c99ad716d15a93828831 | |
parent | 9128ea8abdf8222b4d57c3d6226a47e820746174 (diff) | |
download | cherrypy-35a64b2dce7571bab2e385f99bdb234c9793a219.tar.gz |
Got the --server=modfcgid option to test.py working.
-rw-r--r-- | cherrypy/test/fastcgi.bat | 1 | ||||
-rw-r--r-- | cherrypy/test/fastcgi.py | 37 | ||||
-rw-r--r-- | cherrypy/test/fcgi.conf | 4 | ||||
-rw-r--r-- | cherrypy/test/helper.py | 12 | ||||
-rw-r--r-- | cherrypy/test/modfcgid.py | 86 |
5 files changed, 25 insertions, 115 deletions
diff --git a/cherrypy/test/fastcgi.bat b/cherrypy/test/fastcgi.bat deleted file mode 100644 index b67b9b09..00000000 --- a/cherrypy/test/fastcgi.bat +++ /dev/null @@ -1 +0,0 @@ -python C:\Python25\Lib\site-packages\cherrypy\test\..\cherryd -c C:\Python25\Lib\site-packages\cherrypy\test\test.conf -f -e test_suite -i cherrypy.test.fastcgi
\ No newline at end of file diff --git a/cherrypy/test/fastcgi.py b/cherrypy/test/fastcgi.py deleted file mode 100644 index 8d633737..00000000 --- a/cherrypy/test/fastcgi.py +++ /dev/null @@ -1,37 +0,0 @@ -import cherrypy -from cherrypy.process import plugins, servers -from cherrypy.test import test_caching - -if hasattr(test_caching, 'setup_server'): - test_caching.setup_server() - -def run(): - cherrypy.config.update('C:\\Python25\\Lib\\site-packages\\cherrypy\\test\\test.conf') - - engine = cherrypy.engine - cherrypy.config.update({'environment': 'test_suite'}) - - if hasattr(engine, "signal_handler"): - engine.signal_handler.subscribe() - if hasattr(engine, "console_control_handler"): - engine.console_control_handler.subscribe() - - # Turn off autoreload when using fastcgi. - cherrypy.config.update({'engine.autoreload_on': False}) - cherrypy.server.unsubscribe() - bindAddress = ('127.0.0.1', 4000) - f = servers.FlupFCGIServer(application=cherrypy.tree, bindAddress=bindAddress) - s = servers.ServerAdapter(engine, httpserver=f, bind_addr=bindAddress) - s.subscribe() - - # Always start the engine; this will start all other services - try: - engine.start() - except: - # Assume the error has been logged already via bus.log. - sys.exit(1) - else: - engine.block() - -if __name__ == '__main__': - run() diff --git a/cherrypy/test/fcgi.conf b/cherrypy/test/fcgi.conf index df690bf2..5b987d29 100644 --- a/cherrypy/test/fcgi.conf +++ b/cherrypy/test/fcgi.conf @@ -1,7 +1,7 @@ # Apache2 server conf file for testing CherryPy with mod_fcgid. -DocumentRoot "/" +DocumentRoot "C:\Python25\Lib\site-packages\cherrypy\test" Listen 8080 LoadModule fastcgi_module modules/mod_fastcgi.dll LoadModule rewrite_module modules/mod_rewrite.so @@ -10,4 +10,4 @@ Options ExecCGI SetHandler fastcgi-script RewriteEngine On RewriteRule ^(.*)$ /fastcgi.pyc [L] -FastCgiServer "C:\\Python25\\Lib\\site-packages\\cherrypy\\test\\fastcgi.pyc" -port 4000 +FastCgiExternalServer "C:\\Python25\\Lib\\site-packages\\cherrypy\\test\\fastcgi.pyc" -host 127.0.0.1:4000 diff --git a/cherrypy/test/helper.py b/cherrypy/test/helper.py index af4ebb08..e34ca80a 100644 --- a/cherrypy/test/helper.py +++ b/cherrypy/test/helper.py @@ -147,7 +147,17 @@ def sync_apps(profile=False, validate=False, conquer=False): warnings.warn("Error importing wsgiref. The validator will not run.") else: app = validate.validator(app) - cherrypy.server.httpserver.wsgi_app = app + + h = cherrypy.server.httpserver + if hasattr(h, 'wsgi_app'): + # CherryPy's wsgiserver + h.wsgi_app = app + elif hasattr(h, 'fcgiserver'): + # flup's WSGIServer + h.fcgiserver.application = app + elif hasattr(h, 'scgiserver'): + # flup's WSGIServer + h.scgiserver.application = app def _run_test_suite_thread(moduleNames, conf): try: diff --git a/cherrypy/test/modfcgid.py b/cherrypy/test/modfcgid.py index 71c10b59..47ee1960 100644 --- a/cherrypy/test/modfcgid.py +++ b/cherrypy/test/modfcgid.py @@ -39,6 +39,8 @@ import re import sys import time +import cherrypy +from cherrypy.process import plugins, servers from cherrypy.test import test @@ -70,10 +72,10 @@ Options ExecCGI SetHandler fastcgi-script RewriteEngine On RewriteRule ^(.*)$ /fastcgi.pyc [L] -FastCgiServer "%(server)s" -port 4000 +FastCgiExternalServer "%(server)s" -host 127.0.0.1:4000 """ -def start(testmod, host, port, conf_template): +def start_apache(host, port, conf_template): fcgiconf = CONF_PATH if not os.path.isabs(fcgiconf): fcgiconf = os.path.join(curdir, fcgiconf) @@ -89,53 +91,6 @@ def start(testmod, host, port, conf_template): finally: f.close() - # Write the .py file to import testmod and run setup_server - # Import it immediately so we get a .pyc file. - f = open(os.path.join(curdir, 'fastcgi.py'), 'wb') - try: - f.write("""import cherrypy -from cherrypy.process import plugins, servers -from cherrypy.test import %s - -if hasattr(%s, 'setup_server'): - %s.setup_server() - -def run(): - cherrypy.config.update(%r) - - engine = cherrypy.engine - cherrypy.config.update({'environment': 'test_suite'}) - - if hasattr(engine, "signal_handler"): - engine.signal_handler.subscribe() - if hasattr(engine, "console_control_handler"): - engine.console_control_handler.subscribe() - - # Turn off autoreload when using fastcgi. - cherrypy.config.update({'engine.autoreload_on': False}) - cherrypy.server.unsubscribe() - bindAddress = ('127.0.0.1', 4000) - f = servers.FlupFCGIServer(application=cherrypy.tree, bindAddress=bindAddress) - s = servers.ServerAdapter(engine, httpserver=f, bind_addr=bindAddress) - s.subscribe() - - # Always start the engine; this will start all other services - try: - engine.start() - except: - # Assume the error has been logged already via bus.log. - sys.exit(1) - else: - engine.block() - -if __name__ == '__main__': - run() -""" % (testmod, testmod, testmod, os.path.join(curdir, 'test.conf'))) - finally: - f.close() - from cherrypy.test import fastcgi - reload(fastcgi) - result = read_process(APACHE_PATH, "-k start -f %s" % fcgiconf) if result: print result @@ -149,29 +104,12 @@ class FCGITestHarness(test.TestHarness): """TestHarness for fcgid and CherryPy.""" def _run(self, conf): - from cherrypy.test import webtest - webtest.WebCase.PORT = self.port - webtest.WebCase.harness = self - webtest.WebCase.scheme = "http" - webtest.WebCase.interactive = self.interactive - print - print "Running tests:", self.server - - conf_template = conf_fcgid - - # Since cherryd is run by the Apache process, Apache must be - # started separately for each test. - success = True - for testmod in self.tests: - try: - start(testmod, self.host, self.port, conf_template) - suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) - result = webtest.TerseTestRunner(verbosity=2).run(suite) - success &= result.wasSuccessful() - finally: - stop() - if success: - return 0 - else: - return 1 + cherrypy.server.httpserver = servers.FlupFCGIServer( + application=cherrypy.tree, bindAddress=('127.0.0.1', 4000)) + cherrypy.server.httpserver.bind_addr = ('127.0.0.1', 4000) + try: + start_apache(self.host, self.port, conf_fcgid) + return test.TestHarness._run(self, conf) + finally: + stop() |