mirror of
https://github.com/denoland/deno.git
synced 2025-10-03 15:44:36 +00:00
Enable http server for tests.
This commit is contained in:
parent
8aa0408671
commit
f7fd238953
2 changed files with 35 additions and 0 deletions
31
tools/http_server.py
Executable file
31
tools/http_server.py
Executable file
|
@ -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()
|
|
@ -6,6 +6,8 @@ import sys
|
||||||
from check_output_test import check_output_test
|
from check_output_test import check_output_test
|
||||||
from util import executable_suffix, run, build_path
|
from util import executable_suffix, run, build_path
|
||||||
from util_test import util_test
|
from util_test import util_test
|
||||||
|
import subprocess
|
||||||
|
import http_server
|
||||||
|
|
||||||
|
|
||||||
def check_exists(filename):
|
def check_exists(filename):
|
||||||
|
@ -24,6 +26,8 @@ def main(argv):
|
||||||
print "Usage: tools/test.py [build_dir]"
|
print "Usage: tools/test.py [build_dir]"
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
http_server.spawn()
|
||||||
|
|
||||||
# Internal tools testing
|
# Internal tools testing
|
||||||
util_test()
|
util_test()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue