aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJukka Jylänki <jujjyl@gmail.com>2013-11-16 13:40:46 +0200
committerJukka Jylänki <jujjyl@gmail.com>2013-11-16 13:42:19 +0200
commit59bb612978c61fcfc069803f2f0d89bb604e0e78 (patch)
treeaab35541a6914d6b191c3afd25ea23e2f382574f
parentb8ac3d2a175799678691bd123d7e1cb1d42b46f8 (diff)
Fix HTTP server in browser harness to serve files with appropriate header and body content by using the python built-in SimpleHTTPServer for file serves instead of manually crafting header+body. Fixes browser test harness runs on Windows and Linux.
-rwxr-xr-xtests/runner.py24
1 files changed, 8 insertions, 16 deletions
diff --git a/tests/runner.py b/tests/runner.py
index 7f513635..34435383 100755
--- a/tests/runner.py
+++ b/tests/runner.py
@@ -16,7 +16,7 @@ so you may prefer to use fewer cores here.
'''
from subprocess import Popen, PIPE, STDOUT
-import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, multiprocessing, functools, stat, string
+import os, unittest, tempfile, shutil, time, inspect, sys, math, glob, re, difflib, webbrowser, hashlib, threading, platform, BaseHTTPServer, SimpleHTTPServer, multiprocessing, functools, stat, string
# Setup
@@ -491,22 +491,14 @@ def harness_server_func(q):
httpd.serve_forever() # test runner will kill us
def server_func(dir, q):
- class TestServerHandler(BaseHTTPServer.BaseHTTPRequestHandler):
- def do_GET(s):
- if 'report_' in s.path:
- q.put(s.path)
+ class TestServerHandler(SimpleHTTPServer.SimpleHTTPRequestHandler):
+ def do_GET(self):
+ if 'report_' in self.path:
+ q.put(self.path)
else:
- filename = s.path.split('?')[0][1:]
- if os.path.exists(filename):
- s.send_response(200)
- s.send_header("Content-type", "text/html")
- s.end_headers()
- s.wfile.write(open(filename).read())
- s.wfile.close()
- else:
- s.send_response(500)
- s.send_header("Content-type", "text/html")
- s.end_headers()
+ # Use SimpleHTTPServer default file serving operation for GET.
+ SimpleHTTPServer.SimpleHTTPRequestHandler.do_GET(self)
+
def log_request(code=0, size=0):
# don't log; too noisy
pass