summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2018-08-15 19:08:03 -0400
committerRyan Dahl <ry@tinyclouds.org>2018-08-20 16:53:39 -0400
commitf7fd2389533f0ae387af30ea63755b67a6484e51 (patch)
treee70daea8675e86293f8675ff3eb3c00f9e0629bd
parent8aa04086719d2089920714e00de45d3af99ef5f5 (diff)
Enable http server for tests.
-rwxr-xr-xtools/http_server.py31
-rwxr-xr-xtools/test.py4
2 files changed, 35 insertions, 0 deletions
diff --git a/tools/http_server.py b/tools/http_server.py
new file mode 100755
index 000000000..a3e6adf44
--- /dev/null
+++ b/tools/http_server.py
@@ -0,0 +1,31 @@
+#!/usr/bin/env python
+# Many tests expect there to be an http server on port 4545 servering the deno
+# root directory.
+import os
+from threading import Thread
+import SimpleHTTPServer
+import SocketServer
+from util import root_path
+from time import sleep
+
+PORT = 4545
+
+
+def serve_forever():
+ os.chdir(root_path) # Hopefully the main thread doesn't also chdir.
+ Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
+ httpd = SocketServer.TCPServer(("", PORT), Handler)
+ print "Deno test server http://localhost:%d/" % PORT
+ httpd.serve_forever()
+
+
+def spawn():
+ thread = Thread(target=serve_forever)
+ thread.daemon = True
+ thread.start()
+ sleep(1) # TODO I'm too lazy to figure out how to do this properly.
+ return thread
+
+
+if __name__ == '__main__':
+ serve_forever()
diff --git a/tools/test.py b/tools/test.py
index 5344e7b62..75886874e 100755
--- a/tools/test.py
+++ b/tools/test.py
@@ -6,6 +6,8 @@ import sys
from check_output_test import check_output_test
from util import executable_suffix, run, build_path
from util_test import util_test
+import subprocess
+import http_server
def check_exists(filename):
@@ -24,6 +26,8 @@ def main(argv):
print "Usage: tools/test.py [build_dir]"
sys.exit(1)
+ http_server.spawn()
+
# Internal tools testing
util_test()