From 64b8938f0b39acdffb5d5f8c22933e436796efa9 Mon Sep 17 00:00:00 2001 From: Benjamin Sparks Date: Wed, 28 May 2025 16:03:56 +0200 Subject: [PATCH] python3Packages.wgpu-py: combine passthru tests into one `installCheckPhase` --- .../python-modules/wgpu-py/default.nix | 62 ++++--------------- 1 file changed, 13 insertions(+), 49 deletions(-) diff --git a/pkgs/development/python-modules/wgpu-py/default.nix b/pkgs/development/python-modules/wgpu-py/default.nix index 3b6ad952e907..fe5b84f5539c 100644 --- a/pkgs/development/python-modules/wgpu-py/default.nix +++ b/pkgs/development/python-modules/wgpu-py/default.nix @@ -33,8 +33,8 @@ trio, # passthru - wgpu-py, testers, + wgpu-py, }: buildPythonPackage rec { pname = "wgpu-py"; @@ -103,62 +103,26 @@ buildPythonPackage rec { trio ]; - # Tests break due in Linux CI due to wgpu being unable to find any adapters. + # Tests break in Linux CI due to wgpu being unable to find any adapters. # Ordinarily, this would be fixed in an approach similar to `pkgs/by-name/wg/wgpu-native/examples.nix`'s # usage of `runtimeInputs` and `makeWrapperArgs`. # Unfortunately, as this is a Python module without a `mainProgram`, `makeWrapperArgs` will not apply here, # as there is no "script" to wrap. - # - # In addition thereto, the structure of the tests in `wgpu-py` is unconventional, spread in separate folders - # all in the repository's root, which causes `pytestCheckHook` to fail for Darwin platforms too. - # As such, we delegate testing to `passthru`. - doCheck = false; + doCheck = stdenv.hostPlatform.isDarwin; - passthru = { - tests = - { - version = testers.testVersion { - package = wgpu-py; - command = "python3 -c 'import wgpu; print(wgpu.__version__)'"; - }; - } - // lib.optionalAttrs stdenv.buildPlatform.isDarwin { - tests = testers.runCommand { - name = "tests"; - script = '' - WGPU_LIB_PATH=${wgpu-native}/lib/libwgpu_native${stdenv.hostPlatform.extensions.library} \ - pytest -v ${wgpu-py.src}/tests - ''; - nativeBuildInputs = [ wgpu-py ] ++ nativeCheckInputs; - }; + installCheckPhase = '' + runHook preInstallCheck - examples = testers.runCommand { - name = "examples"; - script = '' - WGPU_LIB_PATH=${wgpu-native}/lib/libwgpu_native${stdenv.hostPlatform.extensions.library} \ - pytest -v ${wgpu-py.src}/examples - ''; - nativeBuildInputs = [ wgpu-py ] ++ nativeCheckInputs; - }; + for suite in tests examples codegen tests_mem; do + pytest -v $suite + done - codegen = testers.runCommand { - name = "codegen"; - script = '' - WGPU_LIB_PATH=${wgpu-native}/lib/libwgpu_native${stdenv.hostPlatform.extensions.library} \ - pytest -v ${wgpu-py.src}/codegen - ''; - nativeBuildInputs = [ wgpu-py ] ++ nativeCheckInputs; - }; + runHook postInstallCheck + ''; - tests_mem = testers.runCommand { - name = "tests_mem"; - script = '' - WGPU_LIB_PATH=${wgpu-native}/lib/libwgpu_native${stdenv.hostPlatform.extensions.library} \ - pytest -v ${wgpu-py.src}/tests_mem - ''; - nativeBuildInputs = [ wgpu-py ] ++ nativeCheckInputs; - }; - }; + passthru.tests.version = testers.testVersion { + package = wgpu-py; + command = "python3 -c 'import wgpu; print(wgpu.__version__)'"; }; meta = {