Skip to content

Commit

Permalink
Enable example screenshot tests again (#350)
Browse files Browse the repository at this point in the history
* Enable example screenshot tests again

* Use default lavapipe
  • Loading branch information
almarklein authored Feb 23, 2023
1 parent 39fc6b0 commit 794960c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
6 changes: 2 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ jobs:
- name: Install llvmpipe and lavapipe for offscreen canvas
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Install dev dependencies
run: |
Expand All @@ -122,6 +120,8 @@ jobs:
python download-wgpu-native.py
pip install -e .
- name: Test examples
env:
EXPECT_LAVAPIPE: true
run: |
pytest -v examples
Expand Down Expand Up @@ -184,8 +184,6 @@ jobs:
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update -y -qq
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
sudo apt-get update
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
- name: Install dev dependencies
run: |
Expand Down
7 changes: 7 additions & 0 deletions examples/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from testutils import (
can_use_wgpu_lib,
wgpu_backend,
is_lavapipe,
find_examples,
ROOT,
Expand Down Expand Up @@ -63,6 +64,12 @@ def mock_time():
yield


def test_that_we_are_on_lavapipe():
print(wgpu_backend)
if os.getenv("EXPECT_LAVAPIPE"):
assert is_lavapipe


@pytest.mark.parametrize("module", examples_to_test)
def test_examples_screenshots(
module, pytestconfig, force_offscreen, mock_time, request
Expand Down
14 changes: 7 additions & 7 deletions tests/testutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,11 @@ def _determine_can_use_glfw():
return True


def wgpu_backend_endswith(query):
def get_wgpu_backend():
"""
Query the configured wgpu backend driver.
"""
code = "import wgpu.utils; d = wgpu.utils.get_default_device(); print(d.adapter.properties['adapterType'], d.adapter.properties['backendType'])"
code = "import wgpu.utils; info = wgpu.utils.get_default_device().adapter.request_adapter_info(); print(info['adapter_type'], info['backend_type'])"
result = subprocess.run(
[
sys.executable,
Expand All @@ -114,10 +114,9 @@ def wgpu_backend_endswith(query):
universal_newlines=True,
cwd=ROOT,
)
return (
result.stdout.strip().endswith(query)
and "traceback" not in result.stderr.lower()
)
out = result.stdout.strip()
err = result.stderr.strip()
return err if "traceback" in err.lower() else out


def find_examples(query=None, negative_query=None, return_stems=False):
Expand All @@ -139,4 +138,5 @@ def find_examples(query=None, negative_query=None, return_stems=False):
can_use_wgpu_lib = _determine_can_use_wgpu_lib()
can_use_glfw = _determine_can_use_glfw()
is_ci = bool(os.getenv("CI", None))
is_lavapipe = wgpu_backend_endswith("CPU Vulkan")
wgpu_backend = get_wgpu_backend()
is_lavapipe = wgpu_backend.lower() == "cpu vulkan"

0 comments on commit 794960c

Please sign in to comment.