| | 176 | testDict = { |
|---|
| | 177 | 'baseurlFilter' : 'test_baseurl_filter', |
|---|
| | 178 | 'cacheFilter' : 'test_cache_filter', |
|---|
| | 179 | 'combinedFilters' : 'test_combinedfilters', |
|---|
| | 180 | 'core' : 'test_core', |
|---|
| | 181 | 'decodingEncodingFilter' : 'test_decodingencoding_filter', |
|---|
| | 182 | 'gzipFilter' : 'test_gzip_filter', |
|---|
| | 183 | 'logDebugInfoFilter' : 'test_logdebuginfo_filter', |
|---|
| | 184 | 'objectMapping' : 'test_objectmapping', |
|---|
| | 185 | 'staticFilter' : 'test_static_filter', |
|---|
| | 186 | 'tutorials' : 'test_tutorials', |
|---|
| | 187 | 'virtualHostFilter' : 'test_virtualhost_filter' |
|---|
| | 188 | } |
|---|
| | 189 | |
|---|
| | 190 | import sys |
|---|
| | 191 | |
|---|
| | 192 | def help(): |
|---|
| | 193 | print """CherryPy Test Program |
|---|
| | 194 | Usage: |
|---|
| | 195 | test.py -mode testName1 testName2 testName... |
|---|
| | 196 | |
|---|
| | 197 | modes: wsgi, severless, native, all |
|---|
| | 198 | default: wsgi |
|---|
| | 199 | """ |
|---|
| | 200 | |
|---|
| | 201 | print ' tests:' |
|---|
| | 202 | for testString in testDict: |
|---|
| | 203 | print ' ', testString |
|---|
| | 204 | |
|---|
| | 205 | |
|---|
| | 206 | class BadArgument(Exception): |
|---|
| | 207 | def __init__(self, arg): |
|---|
| | 208 | self.arg = arg |
|---|
| | 209 | def __str__(self): |
|---|
| | 210 | return 'Error:\n %s is not a valid option.' % self.arg |
|---|
| | 211 | |
|---|
| | 212 | class DisplayHelp(Exception): pass |
|---|
| | 213 | |
|---|
| | 214 | def getOptions(): |
|---|
| | 215 | |
|---|
| | 216 | argSet = set([arg.lower() for arg in sys.argv[1:]]) |
|---|
| | 217 | |
|---|
| | 218 | if '-help' in sys.argv: |
|---|
| | 219 | raise DisplayHelp |
|---|
| | 220 | |
|---|
| | 221 | servers = set() |
|---|
| | 222 | if '-all' in argSet: |
|---|
| | 223 | servers.update(['wsgi', 'native', 'serverless']) |
|---|
| | 224 | elif '-wsgi' in argSet: |
|---|
| | 225 | servers.add('wsgi') |
|---|
| | 226 | elif '-native' in argSet: |
|---|
| | 227 | servers.add('native') |
|---|
| | 228 | elif '-serverless' in argSet: |
|---|
| | 229 | servers.add('serverless') |
|---|
| | 230 | else: |
|---|
| | 231 | servers.add('wsgi') |
|---|
| | 232 | |
|---|
| | 233 | argSet.difference(['-wsgi', '-native', '-serverless', '-all']) |
|---|
| | 234 | |
|---|
| | 235 | tests = [] |
|---|
| | 236 | for testString, test in testDict.iteritems(): |
|---|
| | 237 | if testString.lower() in argSet: |
|---|
| | 238 | tests.append(testDict[testString]) |
|---|
| | 239 | argSet.discard(testString.lower()) |
|---|
| | 240 | |
|---|
| | 241 | if not tests: |
|---|
| | 242 | tests = testDict.values() |
|---|
| | 243 | |
|---|
| | 244 | if len(argSet): |
|---|
| | 245 | for arg in sys.argv: |
|---|
| | 246 | if arg.lower() in argSet: |
|---|
| | 247 | raise BadArgument(arg) |
|---|
| | 248 | return (servers, tests) |
|---|
| | 303 | if 'serverless' in servers: |
|---|
| | 304 | print |
|---|
| | 305 | print "Running testList: Serverless" |
|---|
| | 306 | cherrypy.codecoverage = True |
|---|
| | 307 | run_test_suite(testList, None, server_conf) |
|---|
| | 308 | cherrypy.codecoverage = False |
|---|
| | 309 | |
|---|
| | 310 | if 'native' in servers: |
|---|
| | 311 | print |
|---|
| | 312 | print "Running testList: Native HTTP Server" |
|---|
| | 313 | run_test_suite(testList, "cherrypy._cphttpserver.embedded_server", server_conf) |
|---|
| | 314 | |
|---|
| | 315 | if 'wsgi' in servers: |
|---|
| | 316 | print |
|---|
| | 317 | print "Running testList: Native WSGI Server" |
|---|
| | 318 | server_conf['profiling.on'] = True |
|---|
| | 319 | run_test_suite(testList, "cherrypy._cpwsgi.WSGIServer", server_conf) |
|---|
| | 320 | del server_conf['profiling.on'] |
|---|
| | 321 | |
|---|
| 236 | | print "Running tests: Serverless" |
|---|
| 237 | | cherrypy.codecoverage = True |
|---|
| 238 | | run_test_suite(testList, None, server_conf) |
|---|
| 239 | | cherrypy.codecoverage = False |
|---|
| 240 | | |
|---|
| 241 | | print |
|---|
| 242 | | print "Running tests: Native HTTP Server" |
|---|
| 243 | | run_test_suite(testList, "cherrypy._cphttpserver.embedded_server", server_conf) |
|---|
| 244 | | |
|---|
| 245 | | print |
|---|
| 246 | | print "Running tests: Native WSGI Server" |
|---|
| 247 | | server_conf['profiling.on'] = True |
|---|
| 248 | | run_test_suite(testList, "cherrypy._cpwsgi.WSGIServer", server_conf) |
|---|
| 249 | | del server_conf['profiling.on'] |
|---|