Skip to content

Commit 794960c

Browse files
authored
Enable example screenshot tests again (#350)
* Enable example screenshot tests again * Use default lavapipe
1 parent 39fc6b0 commit 794960c

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,6 @@ jobs:
112112
- name: Install llvmpipe and lavapipe for offscreen canvas
113113
run: |
114114
sudo apt-get update -y -qq
115-
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
116-
sudo apt-get update
117115
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
118116
- name: Install dev dependencies
119117
run: |
@@ -122,6 +120,8 @@ jobs:
122120
python download-wgpu-native.py
123121
pip install -e .
124122
- name: Test examples
123+
env:
124+
EXPECT_LAVAPIPE: true
125125
run: |
126126
pytest -v examples
127127
@@ -184,8 +184,6 @@ jobs:
184184
if: matrix.os == 'ubuntu-latest'
185185
run: |
186186
sudo apt-get update -y -qq
187-
sudo add-apt-repository ppa:oibaf/graphics-drivers -y
188-
sudo apt-get update
189187
sudo apt install -y libegl1-mesa libgl1-mesa-dri libxcb-xfixes0-dev mesa-vulkan-drivers
190188
- name: Install dev dependencies
191189
run: |

examples/tests/test_examples.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
from testutils import (
1717
can_use_wgpu_lib,
18+
wgpu_backend,
1819
is_lavapipe,
1920
find_examples,
2021
ROOT,
@@ -63,6 +64,12 @@ def mock_time():
6364
yield
6465

6566

67+
def test_that_we_are_on_lavapipe():
68+
print(wgpu_backend)
69+
if os.getenv("EXPECT_LAVAPIPE"):
70+
assert is_lavapipe
71+
72+
6673
@pytest.mark.parametrize("module", examples_to_test)
6774
def test_examples_screenshots(
6875
module, pytestconfig, force_offscreen, mock_time, request

tests/testutils.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ def _determine_can_use_glfw():
9898
return True
9999

100100

101-
def wgpu_backend_endswith(query):
101+
def get_wgpu_backend():
102102
"""
103103
Query the configured wgpu backend driver.
104104
"""
105-
code = "import wgpu.utils; d = wgpu.utils.get_default_device(); print(d.adapter.properties['adapterType'], d.adapter.properties['backendType'])"
105+
code = "import wgpu.utils; info = wgpu.utils.get_default_device().adapter.request_adapter_info(); print(info['adapter_type'], info['backend_type'])"
106106
result = subprocess.run(
107107
[
108108
sys.executable,
@@ -114,10 +114,9 @@ def wgpu_backend_endswith(query):
114114
universal_newlines=True,
115115
cwd=ROOT,
116116
)
117-
return (
118-
result.stdout.strip().endswith(query)
119-
and "traceback" not in result.stderr.lower()
120-
)
117+
out = result.stdout.strip()
118+
err = result.stderr.strip()
119+
return err if "traceback" in err.lower() else out
121120

122121

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

0 commit comments

Comments
 (0)