import sys
from subprocess import Popen, PIPE
from time import sleep
import requests

def get_with_retries(url):
    n = 0
    while True:
        try:
            return requests.get(url)
        except requests.ConnectionError:
            if n < 5:
                n += 1
                sleep(0.1)
            else:
                raise

def test_standalone_serves_html():
    process = Popen([sys.executable, '-c', 'from jasmine.entry_points import standalone; standalone()', '--config', 'test/fixture_files/jasmine.yml'])
    try:
        req = get_with_retries('http://localhost:8888/')

        assert req.status_code == 200
        assert 'main.js' in req.text
        assert 'main.css' in req.text
        assert '__spec__/someSpec.js' in req.text
    finally:
        process.terminate()

def test_ci():
    process = Popen([sys.executable, '-c', 'from jasmine.entry_points import continuous_integration; continuous_integration()', '--config', 'test/fixture_files/jasmine.yml'], stdout=PIPE)
    output = process.communicate()[0]
    process.wait()
    
    assert process.returncode == 0
    assert '1 specs, 0 failed' in str(output)

import sys
from subprocess import Popen, PIPE
from time import sleep
import requests

def get_with_retries(url):
    n = 0
    while True:
        try:
            return requests.get(url)
        except requests.ConnectionError:
            if n < 20:
                n += 1
                sleep(0.1)
            else:
                raise

def test_standalone_serves_html():
    process = Popen([sys.executable, '-c', 'from jasmine.entry_points import standalone; standalone()', '--config', 'test/fixture_files/jasmine.yml'])
    try:
        req = get_with_retries('http://localhost:8888/')

        assert req.status_code == 200
        assert 'main.js' in req.text
        assert 'main.css' in req.text
        assert '__spec__/someSpec.js' in req.text
    finally:
        process.terminate()

def test_ci():
    process = Popen([sys.executable, '-c', 'from jasmine.entry_points import continuous_integration; continuous_integration()', '--config', 'test/fixture_files/jasmine.yml'], stdout=PIPE)
    output = process.communicate()[0]
    process.wait()
    
    assert process.returncode == 0
    assert '1 specs, 0 failed' in str(output)

Allow more time for jasmine to start up in tests
Allow more time for jasmine to start up in tests
