Skip to content

Commit

Permalink
Test all tests and skip on screen rendering tests if no display avail…
Browse files Browse the repository at this point in the history
…able (#557)

authored by Kevin Lin
  • Loading branch information
kevin-thankyou-lin authored Nov 15, 2024
1 parent f8a9de1 commit 4f7e03f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/run-tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,4 @@ jobs:
run: |
export PYOPENGL_PLATFORM="osmesa"
export MUJOCO_GL="osmesa"
python3 tests/test_robots/test_all_robots.py
python3 tests/test_grippers/test_all_grippers.py
python3 tests/test_environments/test_all_environments.py
pytest tests/test_controllers/test_composite_controllers.py
pytest
14 changes: 8 additions & 6 deletions tests/test_renderers/test_all_renderers.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
"""
Tests that all renderers are able to render properly.
"""
import os

import numpy as np
import pytest

import robosuite as suite
from robosuite.controllers import load_composite_controller_config


def is_display_available() -> bool:
return "DISPLAY" in os.environ or "WAYLAND_DISPLAY" in os.environ


@pytest.mark.skipif(not is_display_available(), reason="No display available for on-screen rendering.")
def test_mujoco_renderer():
env = suite.make(
env_name="Lift",
Expand All @@ -25,13 +29,13 @@ def test_mujoco_renderer():

low, high = env.action_spec

# do visualization
for i in range(10):
action = np.random.uniform(low, high)
obs, reward, done, _ = env.step(action)
env.render()


@pytest.mark.skipif(not is_display_available(), reason="No display available for on-screen rendering.")
def test_mjviewer_renderer():
env = suite.make(
env_name="Lift",
Expand All @@ -49,7 +53,6 @@ def test_mjviewer_renderer():

low, high = env.action_spec

# do visualization
for i in range(10):
action = np.random.uniform(low, high)
obs, reward, done, _ = env.step(action)
Expand All @@ -72,7 +75,6 @@ def test_offscreen_renderer():

low, high = env.action_spec

# do visualization
for i in range(10):
action = np.random.uniform(low, high)
obs, reward, done, _ = env.step(action)
Expand Down

0 comments on commit 4f7e03f

Please sign in to comment.