Skip to content
Browse files

tests now work on firefox 3

  • Loading branch information...
1 parent a09f8e5 commit 93d67d466f6eeb2d22c5f5c4feddbeeedc0b5c7e Evan Wallace committed Mar 3, 2011
Showing with 29 additions and 3 deletions.
  1. +16 −2 tests.html
  2. +13 −1 tests.py
View
18 tests.html
@@ -25,6 +25,8 @@
document.body.innerHTML += html;
}
+var sockets = [];
+
function socket(pass, fail, expects) {
var sock = new io.Socket('localhost', { port: 5000 });
sock.on('message', function(data) {
@@ -35,6 +37,7 @@
sock.on('disconnect', function() {
fail('lost connection');
});
+ sockets.push(sock);
return sock;
}
@@ -48,7 +51,15 @@
var currentTest = -1;
function nextTest() {
- if (++currentTest < tests.length) {
+ currentTest++;
+
+ // must disconnect sockets because Firefox 3 doesn't
+ // allow more than a few simultaneous connections
+ while (sockets.length > 0) {
+ sockets.pop().disconnect();
+ }
+
+ if (currentTest < tests.length) {
log(tests[currentTest].name + ' ... ');
try {
var current = currentTest;
@@ -57,8 +68,11 @@
}, function(text) {
if (current == currentTest) fail(text);
});
+ setTimeout(function() {
+ if (current == currentTest) fail('timeout after 3 seconds');
+ }, 3000);
} catch (e) {
- fail(e.toString());
+ if (current == currentTest) fail(e.toString());
}
} else {
log('<p>' + numTestsPassed + ' / ' + numTests + ' tests passed</p>');
View
14 tests.py
@@ -25,5 +25,17 @@ def on_message(self, client, message):
def on_disconnect(self, client):
pass
-print '\nopen tests.html to run tests\n'
+def run_server():
+ from SimpleHTTPServer import SimpleHTTPRequestHandler
+ from SocketServer import TCPServer
+ class NiceServer(TCPServer):
+ allow_reuse_address = True
+ NiceServer(('', 8000), SimpleHTTPRequestHandler).serve_forever()
+
+import threading
+t = threading.Thread(target=run_server)
+t.daemon = True
+t.start()
+
+print '\nopen http://localhost:8000/tests.html to run tests\n'
Server().listen(5000)

0 comments on commit 93d67d4

Please sign in to comment.
Something went wrong with that request. Please try again.