Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try fix travis build #613

Merged
merged 2 commits into from Mar 1, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -2,6 +2,7 @@ sudo: false
language: node_js
node_js:
- "4"
- "5"
script:
- npm run test:unit
- npm run test
28 changes: 27 additions & 1 deletion test/run-all-tests.py
Expand Up @@ -56,6 +56,29 @@ def start_server():
env=test_env)
time.sleep(3)

def wait_server_open(server, port, timeout):
import socket
import errno
from time import time as now

# ending time for time out
end = now() + timeout

while True:
s = socket.socket()
try:
next_timeout = end - now() # check for timeout
if next_timeout < 0:
return False

s.connect((server, port))
except socket.error, err:
# if connection failed, try again
s.close()
continue
else:
s.close()
return True

def stop_server():
time.sleep(1)
Expand Down Expand Up @@ -129,7 +152,10 @@ def main():
exit_code = -1
try:
start_server()
exit_code = run_all_tests()
if (wait_server_open('127.0.0.1', 8888, 20)): # time out in 20s
exit_code = run_all_tests()
else:
red_alert('Error open connection')
finally:
stop_server()
sys.exit(exit_code)
Expand Down