Commit 32d06f79 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Have the django test start up the server and get a page

parent 824bdfc6
......@@ -496,7 +496,7 @@ check:
$(PYTHON) $(TOOLS_DIR)/tester.py -R pyston_dbg -j$(TEST_THREADS) -k -a=-n -a=-x -a=-S $(TESTS_DIR) $(ARGS)
@# skip -O for dbg
$(MAKE) run_unittests
$(MAKE) run_unittests ARGS=
@# Building in gcc mode is helpful to find various compiler-specific warnings.
@# We've also discovered UB in our code from running in gcc mode, so try running it as well.
......@@ -936,6 +936,7 @@ $(eval \
$1: nosearch_$1
$1: $(TESTS_DIR)/nosearch_$1 ;
$1: $(TEST_DIR)/cpython/nosearch_$1 ;
$1: $(TEST_DIR)/integration/nosearch_$1 ;
$1: ./microbenchmarks/nosearch_$1 ;
$1: ./minibenchmarks/nosearch_$1 ;
$1: ./benchmarks/nosearch_$1 ;
......
......@@ -78,8 +78,9 @@ static int main(int argc, char** argv) {
int code;
bool force_repl = false;
bool stats = false;
bool unbuffered = false;
const char* command = NULL;
while ((code = getopt(argc, argv, "+OqdIibpjtrsSvnxc:F")) != -1) {
while ((code = getopt(argc, argv, "+OqdIibpjtrsSvnxc:Fu")) != -1) {
if (code == 'O')
FORCE_OPTIMIZE = true;
else if (code == 't')
......@@ -104,6 +105,8 @@ static int main(int argc, char** argv) {
stats = true;
} else if (code == 'S') {
Py_NoSiteFlag = 1;
} else if (code == 'u') {
unbuffered = true;
} else if (code == 'r') {
USE_STRIPPED_STDLIB = true;
} else if (code == 'b') {
......@@ -127,6 +130,12 @@ static int main(int argc, char** argv) {
Py_SetProgramName(argv[0]);
if (unbuffered) {
setvbuf(stdin, (char*)NULL, _IONBF, BUFSIZ);
setvbuf(stdout, (char*)NULL, _IONBF, BUFSIZ);
setvbuf(stderr, (char*)NULL, _IONBF, BUFSIZ);
}
{
Timer _t("for initCodegen");
initCodegen();
......
......@@ -3,8 +3,11 @@
# TODO remove that directive, and also remove it from the subprocess commands down below.
import os
import signal
import subprocess
import sys
import time
import urllib2
EXTRA_PATH = os.path.dirname(__file__) + "/django"
sys.path.insert(0, EXTRA_PATH)
......@@ -14,6 +17,12 @@ from django.core.management import execute_from_command_line
import os
import shutil
is_pyston = True
if is_pyston:
ARGS = "-xu"
else:
ARGS = "-u"
if os.path.exists("testsite"):
print "Removing the existing 'testsite/' directory"
shutil.rmtree("testsite")
......@@ -24,12 +33,51 @@ try:
r = execute_from_command_line()
assert not r
# In theory we could run this in the current process (migrate.py is only a couple lines),
# but I guess the "startproject testsite" command changed enough global state that
# it won't work. So create a new subprocess to run it instead.
print "Running testsite/manage.py migrate"
env = dict(os.environ)
env["PYTHONPATH"] = env.get("PYTHONPATH", "") + ":" + EXTRA_PATH
subprocess.check_call([sys.executable, "-x", "testsite/manage.py", "migrate"], env=env)
# subprocess.check_call([sys.executable, "testsite/manage.py", "runserver", "--noreload"])
os.environ["PYTHONPATH"] = os.environ.get("PYTHONPATH", "") + ":" + EXTRA_PATH
subprocess.check_call([sys.executable, ARGS, "testsite/manage.py", "migrate"])
print "Running runserver localhost:8000"
p = subprocess.Popen([sys.executable, ARGS, "testsite/manage.py", "runserver", "--noreload", "localhost:8000"], stdout=subprocess.PIPE)
try:
print "Waiting for server to start up"
while True:
l = p.stdout.readline()
assert l, "unexpected eof"
print l
if l.startswith("Quit the server with CONTROL-C"):
break
# Give the server some extra time to start up:
time.sleep(1)
print "Server started up, fetching home page"
f = urllib2.urlopen("http://localhost:8000/", timeout=1)
s = f.read()
assert "Congratulations on your first Django-powered page" in s
print "Shutting down server"
# ctrl-C is how you shut down the django development server cleanly, but Pyston doesn't yet support that.
# So you'll see a "SIGINT! someone called about" message and then a traceback on stderr.
p.send_signal(signal.SIGINT)
while True:
l = p.stdout.readline()
if not l:
break
assert "Error" not in l, l
print l
code = p.wait()
# We can enable this assert once we support signals such as ctrl-C:
# assert code == 0
except:
p.kill()
p.wait()
raise
finally:
pass
# shutil.rmtree("testsite")
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment