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

Changeset 1567

Show
Ignore:
Timestamp:
12/28/06 13:26:33
Author:
fumanchu
Message:

2.x backports: [1389] Fix for #481 (buildbot quiet mode). Use test.py --dumb to suppress the interactive test output features, as well as the "hit enter" prompt at the end. Also [1392] Final fix for #481 (buildbot). The test suite now exits with a non-zero code if any of the tests fail.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/cherrypy-2.x/cherrypy/test/helper.py

    r1499 r1567  
    9999    """ 
    100100    setConfig(conf) 
     101    # The Pybots automatic testing system needs the suite to exit 
     102    # with a non-zero value if there were any problems. 
     103    # Might as well stick it in the server... :/ 
     104    cherrypy.server.test_success = True 
    101105    cherrypy.server.start_with_callback(_run_test_suite_thread, 
    102106                                        args = (moduleNames, conf), 
    103107                                        server_class = server) 
     108    if cherrypy.server.test_success: 
     109        return 0 
     110    else: 
     111        return 1 
    104112 
    105113def _run_test_suite_thread(moduleNames, conf): 
     
    118126         
    119127        suite = CPTestLoader.loadTestsFromName(testmod) 
    120         CPTestRunner.run(suite) 
     128        result = CPTestRunner.run(suite) 
     129        cherrypy.server.test_success &= result.wasSuccessful() 
    121130         
    122131        teardown = getattr(m, "teardown_server", None) 
  • branches/cherrypy-2.x/cherrypy/test/modpy.py

    r1498 r1567  
    114114        import webtest 
    115115        webtest.WebCase.PORT = self.port 
     116        webtest.WebCase.interactive = self.interactive 
    116117        print 
    117118        print "Running tests:", self.server 
     
    121122        # must run the setup_server() function for the test. 
    122123        # Then our process can run the actual test. 
     124        test_success = True 
    123125        for testmod in self.tests: 
    124126            try: 
    125127                start(testmod, self.port) 
    126128                suite = webtest.ReloadingTestLoader().loadTestsFromName(testmod) 
    127                 webtest.TerseTestRunner(verbosity=2).run(suite) 
     129                result = webtest.TerseTestRunner(verbosity=2).run(suite) 
     130                test_success &= result.wasSuccessful() 
    128131            finally: 
    129132                stop() 
     133        if test_success: 
     134            return 0 
     135        else: 
     136            return 1 
    130137 
    131138 
  • branches/cherrypy-2.x/cherrypy/test/test.py

    r1523 r1567  
    2020    """A test harness for the CherryPy framework and CherryPy applications.""" 
    2121     
    22     def __init__(self, tests=None, server=None, protocol="HTTP/1.1", port=8000): 
     22    def __init__(self, tests=None, server=None, protocol="HTTP/1.1", 
     23                 port=8000, interactive=True): 
    2324        """Constructor to populate the TestHarness instance. 
    2425         
     
    2728        self.protocol = protocol 
    2829        self.port = port 
     30        self.interactive = interactive 
    2931        self.server = server 
    3032        self.tests = tests or [] 
     
    5052         
    5153        baseconf['server.protocol_version'] = self.protocol 
    52         self._run(baseconf) 
     54        return self._run(baseconf) 
    5355     
    5456    def _run(self, conf): 
     
    6163        import helper 
    6264        webtest.WebCase.PORT = self.port 
     65        webtest.WebCase.interactive = self.interactive 
    6366        print 
    6467        print "Running tests:", self.server 
    65         helper.run_test_suite(self.tests, self.server, conf) 
     68        return helper.run_test_suite(self.tests, self.server, conf) 
    6669 
    6770 
     
    7376    default_server = "wsgi" 
    7477    port = 8080 
     78    interactive = True 
    7579     
    7680    def __init__(self, available_tests, args=sys.argv[1:]): 
     
    8892        self.protocol = "HTTP/1.1" 
    8993         
    90         longopts = ['cover', 'profile', '1.1', 'help', 'basedir=', 'port=', 
    91                     'server='] 
     94        longopts = ['cover', 'profile', 'dumb', '1.1', 'help', 
     95                    'basedir=', 'port=', 'server='] 
    9296        longopts.extend(self.available_tests) 
    9397        try: 
     
    108112            elif o == "--profile": 
    109113                self.profile = True 
     114            elif o == "--dumb": 
     115                self.interactive = False 
    110116            elif o == "--1.0": 
    111117                self.protocol = "HTTP/1.0" 
     
    140146        print """CherryPy Test Program 
    141147    Usage: 
    142         test.py --server=* --port=%s --1.1 --cover --basedir=path --profile --tests** 
     148        test.py --server=* --port=%s --1.1 --cover --basedir=path --profile --dumb --tests** 
    143149         
    144150    """ % self.__class__.port 
     
    152158        print """ 
    153159     
    154     --port=<int>: use a port other than the default (%s) 
    155     --1.1: use HTTP/1.1 servers instead of default HTTP/1.0 
    156      
    157     --cover: turn on code-coverage tool 
     160    --port=<int>: use a port other than the default (%s). 
     161    --1.1: use HTTP/1.1 servers instead of default HTTP/1.0. 
     162     
     163    --cover: turn on the code-coverage tool. 
    158164    --basedir=path: display coverage stats for some path other than cherrypy. 
    159165     
    160     --profile: turn on profiling tool 
     166    --profile: turn on the profiling tool. 
     167    --dumb: turn off the interactive output features. 
    161168    """ % self.__class__.port 
    162169         
     
    260267        if self.server == 'modpy': 
    261268            import modpy 
    262             modpy.ModPythonTestHarness(self.tests, self.server, 
    263                                        self.protocol, self.port).run(conf) 
     269            h = modpy.ModPythonTestHarness(self.tests, self.server, 
     270                                           self.protocol, self.port, 
     271                                           self.interactive) 
    264272        else: 
    265             TestHarness(self.tests, self.server, 
    266                         self.protocol, self.port).run(conf) 
     273            h = TestHarness(self.tests, self.server, 
     274                            self.protocol, self.port, 
     275                            self.interactive) 
     276         
     277        success = h.run(conf) 
    267278         
    268279        if self.profile: 
     
    274285        if self.cover: 
    275286            self.stop_coverage() 
     287         
     288        return success 
    276289 
    277290 
     
    312325        'test_wsgiapp_filter', 
    313326    ] 
    314     CommandLineParser(testList).run() 
    315      
    316     print 
    317     raw_input('hit enter') 
     327    clp = CommandLineParser(testList) 
     328    success = clp.run() 
     329    if clp.interactive: 
     330        print 
     331        raw_input('hit enter') 
     332    sys.exit(success) 
    318333 
    319334 

Hosted by WebFaction

Log in as guest/cpguest to create tickets