From 9d3c44d855c1fd1bd511afea12564988f5137112 Mon Sep 17 00:00:00 2001 From: Andreas Kloeckner <inform@tiker.net> Date: Sun, 27 Jun 2021 00:01:42 -0500 Subject: [PATCH] Tests: use a purpose-built no-transform array context (+test fixture) --- test/test_arraycontext.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/test/test_arraycontext.py b/test/test_arraycontext.py index 1b82254..0f274a7 100644 --- a/test/test_arraycontext.py +++ b/test/test_arraycontext.py @@ -31,19 +31,46 @@ from arraycontext import ( dataclass_array_container, with_container_arithmetic, serialize_container, deserialize_container, freeze, thaw, - FirstAxisIsElementsTag) + FirstAxisIsElementsTag, + PyOpenCLArrayContext) from arraycontext import ( # noqa: F401 pytest_generate_tests_for_array_contexts, _acf) +from arraycontext.pytest import _PytestPyOpenCLArrayContextFactoryWithClass + import logging logger = logging.getLogger(__name__) +# {{{ array context fixture + +class _PyOpenCLArrayContextForTests(PyOpenCLArrayContext): + """Like :class:`PyOpenCLArrayContext`, but applies no program transformations + whatsoever. Only to be used for testing internal to :mod:`arraycontext`. + """ + + def transform_loopy_program(self, t_unit): + return t_unit + + +class _PyOpenCLArrayContextWithHostScalarsForTestsFactory( + _PytestPyOpenCLArrayContextFactoryWithClass): + actx_class = _PyOpenCLArrayContextForTests + + +class _PyOpenCLArrayContextForTestsFactory( + _PyOpenCLArrayContextWithHostScalarsForTestsFactory): + force_device_scalars = True + + pytest_generate_tests = pytest_generate_tests_for_array_contexts([ - "pyopencl", "pyopencl-deprecated", + _PyOpenCLArrayContextForTestsFactory, + _PyOpenCLArrayContextWithHostScalarsForTestsFactory, ]) +# }}} + # {{{ stand-in DOFArray implementation -- GitLab