Skip to content

Commit

Permalink
Merge pull request #66 from jerryz123/headless
Browse files Browse the repository at this point in the history
Added headless coverage
  • Loading branch information
jerryz123 committed Jul 9, 2018
2 parents f952bd0 + 53b1891 commit 53190ff
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,36 @@
language: python
python:
- "3.6"

# command to install dependencies
install:
- pip install -e .
- pip install sphinx==1.6.5 recommonmark sphinx_rtd_theme pyyaml coveralls

env:
global:
- SDL_VIDEODRIVER=dummy
- SDL_AUDIODRIVER=disk

# command to run tests
script:
- cd docs && make html
- python -m fluids --time 100 -v 0 -o birdseye
- python -m fluids --time 100 -v 0 -o grid
- python -m fluids --time 100 -v 0 -o none

- xvfb-run --server-args="-screen 0 1920x1080x16" python -m fluids --time 100 -v 99 -o birdseye
- xvfb-run --server-args="-screen 0 1920x1080x16" python -m fluids --time 100 -v 99 -o grid
- xvfb-run --server-args="-screen 0 1920x1080x16" python -m fluids --time 100 -v 99 -o none

- coverage run -a --source fluids -m fluids --time 100 -v 0 -o birdseye
- coverage run -a --source fluids -m fluids --time 100 -v 0 -o grid
- coverage run -a --source fluids -m fluids --time 100 -v 0 -o none

- xvfb-run --server-args="-screen 0 1920x1080x16" coverage run -a --source fluids -m fluids --time 100 -v 99 -o birdseye
- xvfb-run --server-args="-screen 0 1920x1080x16" coverage run -a --source fluids -m fluids --time 100 -v 99 -o grid
- xvfb-run --server-args="-screen 0 1920x1080x16" coverage run -a --source fluids -m fluids --time 100 -v 99 -o none

after_success:
- coveralls

Expand Down
12 changes: 10 additions & 2 deletions fluids/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ def get_id():
id_index = id_index + 1
return r


class State(object):
def __init__(self,
layout =STATE_CITY,
Expand Down Expand Up @@ -176,7 +177,11 @@ def __init__(self,
fluids_print("State creation complete")
if vis_level:
self.static_surface = pygame.Surface(self.dimensions)
self.static_debug_surface = pygame.Surface(self.dimensions, pygame.SRCALPHA)
try:
self.static_debug_surface = pygame.Surface(self.dimensions, pygame.SRCALPHA)
except ValueError:
fluids_print("WARNING: Alpha channel not available. Visualization may be slow")
self.static_debug_surface = self.static_surface.copy()
for k, obj in iteritems(self.static_objects):
if type(obj) != CrossWalk:
obj.render(self.static_surface)
Expand All @@ -195,7 +200,10 @@ def get_static_debug_surface(self):
return self.static_debug_surface

def get_dynamic_surface(self):
dynamic_surface = pygame.Surface(self.dimensions, pygame.SRCALPHA)
try:
dynamic_surface = pygame.Surface(self.dimensions, pygame.SRCALPHA)
except ValueError:
dynamic_surface = self.static_debug_surface.copy()
for typ in [Pedestrian, TrafficLight, CrossWalkLight]:
for k, obj in iteritems(self.type_map[typ]):
obj.render(dynamic_surface)
Expand Down

0 comments on commit 53190ff

Please sign in to comment.