run-tests: replace inline python handling with more native scheme
Normally changes in tests are reported like this in diffs:
$ cat foo
- a
+ b
Using -i mode lets us update tests when the new results are correct
and/or populate tests with their output.
But with the standard doctest framework, inline Python sections in
tests changes instead result in a big failure report that's unhelpful.
So here, we replace the doctest calls with a simple compile/eval loop.
[ 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,sys,retry:importmsvcrt,osmsvcrt.setmode(sys.stdout.fileno(),os.O_BINARY)msvcrt.setmode(sys.stderr.fileno(),os.O_BINARY)exceptImportError:passheaders=[h.lower()forhinsys.argv[3:]]conn=httplib.HTTPConnection(sys.argv[1])conn.request("GET",sys.argv[2])response=conn.getresponse()printresponse.status,response.reasonforhinheaders:ifresponse.getheader(h,None)isnotNone:print"%s: %s"%(h,response.getheader(h))printdata=response.read()sys.stdout.write(data)if200<=response.status<=299:sys.exit(0)sys.exit(1)