Download Install Tutorial Docs FAQ Tools WikiLicense Team IRC Planet Involvement Shop Book

Changeset 1815

Show
Ignore:
Timestamp:
11/02/07 17:23:02
Author:
lakin
Message:

Adding a unit test which exposes a bug whereby CP exit codes are mistakenly set to 0 by Daemonizer even if there are pending startup errors waiting to be raised.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/cherrypy/test/test_states.py

    r1810 r1815  
    328328            self.fail("Process failed to return nonzero exit code.") 
    329329 
     330    def test_6_Start_Error_With_Daemonize(self): 
     331        if not self.server_class: 
     332            print "skipped (no server) ", 
     333            return 
     334         
     335        # Start the demo script in a new process 
     336        demoscript = os.path.join(os.getcwd(), os.path.dirname(__file__), 
     337                                  "test_states_demo.py") 
     338        host = cherrypy.server.socket_host 
     339        port = cherrypy.server.socket_port 
     340         
     341        # If a process errors during start, it should stop the engine 
     342        # and exit with a non-zero exit code, even if we daemonize soon 
     343        # thereafter. 
     344        args = [sys.executable, demoscript, host, str(port), '-starterror', '-daemonize'] 
     345        if self.scheme == "https": 
     346            args.append('-ssl') 
     347        exit_code = os.spawnl(os.P_WAIT, sys.executable, *args) 
     348        if exit_code == 0: 
     349            self.fail("Process failed to return nonzero exit code.") 
     350        time.sleep(2) # Wait for the daemonized process to exit. 
     351 
    330352 
    331353class DaemonizeTest(helper.CPWebCase): 
  • trunk/cherrypy/test/test_states_demo.py

    r1810 r1815  
    3737            "server.socket_port": int(sys.argv[2]), 
    3838            "log.screen": False, 
     39            "log.error_file": os.path.join(thisdir, 'test_states_demo.error.log'), 
    3940            } 
    4041     
     
    6162        plugins.PIDFile(cherrypy.engine, PID_file_path).subscribe() 
    6263     
    63     cherrypy.engine.subscribe('start', cherrypy.server.quickstart
     64    cherrypy.engine.subscribe('start', cherrypy.server.quickstart, priority=75
    6465     
    6566    if '-starterror' in sys.argv[3:]: 
    66         cherrypy.engine.subscribe('start', lambda: 1/0
     67        cherrypy.engine.subscribe('start', lambda: 1/0, priority=6
    6768     
    6869    # This is in a special order for a reason: 

Hosted by WebFaction

Log in as guest/cpguest to create tickets