run-tests: test result shows when a failed test could not start a server
Failing to start a server happens regularly, at least on windows buildbot.
Such a failure often has nothing to do with the test, but with the environment.
But half the test output can change because some data is missing. Therefore this
is worth an extended error message.
Detect the server failure in the diff output because it is most reliable
there. Checking the output only does not show if the server failure was
expected.
Old failure message when server start failed:
Failed test-serve.t: output changed
New message:
Failed test-serve.t: serve failed and output changed
[ original upstream message ]
#!/usr/bin/env python"""This does HTTP GET requests given a host:port and path and returnsa subset of the headers plus the body of the result."""importhttplib,systry:importmsvcrt,osmsvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)msvcrt.setmode(sys.stderr.fileno(),os.O_BINARY)exceptImportError:passtwice=Falseif'--twice'insys.argv:sys.argv.remove('--twice')twice=Trueheaderonly=Falseif'--headeronly'insys.argv:sys.argv.remove('--headeronly')headeronly=Truereasons={'Not modified':'Not Modified'}# python 2.4tag=Nonedefrequest(host,path,show):assertnotpath.startswith('/'),pathglobaltagheaders={}iftag:headers['If-None-Match']=tagconn=httplib.HTTPConnection(host)conn.request("GET",'/'+path,None,headers)response=conn.getresponse()printresponse.status,reasons.get(response.reason,response.reason)ifshow[:1]==['-']:show=sorted(hforh,vinresponse.getheaders()ifh.lower()notinshow)forhin[h.lower()forhinshow]:ifresponse.getheader(h,None)isnotNone:print"%s: %s"%(h,response.getheader(h))ifnotheaderonly:printifresponse.status!=500:data=response.read()sys.stdout.write(data)iftwiceandresponse.getheader('ETag',None):tag=response.getheader('ETag')returnresponse.statusstatus=request(sys.argv[1],sys.argv[2],sys.argv[3:])iftwice:status=request(sys.argv[1],sys.argv[2],sys.argv[3:])if200<=status<=305:sys.exit(0)sys.exit(1)