Skip to content

Commit

Permalink
add support for xdist
Browse files Browse the repository at this point in the history
  • Loading branch information
galipremsagar committed Feb 3, 2025
1 parent 009edac commit 5651c00
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from __future__ import annotations

import glob
import os
import pickle
from typing import TYPE_CHECKING, BinaryIO
Expand Down Expand Up @@ -85,19 +86,25 @@ def get_full_nodeid(pyfuncitem):
return full_nodeid


def read_all_results(pattern):
results = {}
for filepath in glob.glob(pattern):
with open(filepath, "rb") as f:
results.update(dict(read_results(f)))
return results


def pytest_configure(config: _pytest.config.Config):
gold_basename = "results-gold"
cudf_basename = "results-cudf-pandas"
test_folder = os.path.join(os.path.dirname(__file__))

if config.getoption("--compare"):
gold_path = os.path.join(test_folder, f"{gold_basename}.pickle")
cudf_path = os.path.join(test_folder, f"{cudf_basename}.pickle")
gold_path = os.path.join(test_folder, f"{gold_basename}*.pickle")
cudf_path = os.path.join(test_folder, f"{cudf_basename}*.pickle")
with disable_module_accelerator():
with open(gold_path, "rb") as f:
gold_results = dict(read_results(f))
with open(cudf_path, "rb") as f:
cudf_results = dict(read_results(f))
gold_results = read_all_results(gold_path)
cudf_results = read_all_results(cudf_path)
config.stash[results] = (gold_results, cudf_results)
else:
# Strip whitespace from each plugin name before checking
Expand Down

0 comments on commit 5651c00

Please sign in to comment.