Skip to content

Commit

Permalink
Merge pull request #206 from qiboteam/gpu_only_selfhosted
Browse files Browse the repository at this point in the history
Option to run only gpu tests in conftest
  • Loading branch information
BrunoLiegiBastonLiegi authored Feb 7, 2025
2 parents b0bde8b + 9c4d8cb commit c2b8bda
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 21 deletions.
39 changes: 20 additions & 19 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion selfhosted
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ cd "$TMP_DIR/tests"

source /nfs/users/github/actions-runner/_work/qibojit/qibojit/testenv/bin/activate

pytest
pytest --gpu-only

pytest_status=$?

if [[ $pytest_status -ne 0 ]]
Expand Down
15 changes: 14 additions & 1 deletion src/qibojit/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

from qibojit.backends import CupyBackend, CuQuantumBackend, NumbaBackend


def pytest_addoption(parser):
parser.addoption(
"--gpu-only",
action="store_true",
default=False,
help="Run on GPU backends only.",
)


BACKENDS = {"numba": NumbaBackend, "cupy": CupyBackend, "cuquantum": CuQuantumBackend}

# ignore backends that are not available in the current testing environment
Expand All @@ -15,7 +25,10 @@


@pytest.fixture
def backend(backend_name):
def backend(backend_name, request):
if request.config.getoption("--gpu-only"): # pragma: no cover
if backend_name not in ("cupy", "cuquantum"):
pytest.skip("Skipping non-gpu backend.")
yield BACKENDS.get(backend_name)()


Expand Down

0 comments on commit c2b8bda

Please sign in to comment.