From faeecf8757360775d0077f37aafcbbad9bd1626f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81opaciuk?= Date: Wed, 22 Mar 2023 13:10:05 +0100 Subject: [PATCH] fix a precompiled kernel test MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The test was not testing actually loading kernels from a file. This was caused by the fact that a supposedly fresh tracker would reuse the same CPU context, and thus, the previous kernel. Signed-off-by: Szymon Łopaciuk --- tests/test_prebuild_kernels.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/test_prebuild_kernels.py b/tests/test_prebuild_kernels.py index 5b63698c1..b0b1a23b9 100644 --- a/tests/test_prebuild_kernels.py +++ b/tests/test_prebuild_kernels.py @@ -6,6 +6,7 @@ import cffi +import xobjects as xo import xpart as xp import xtrack as xt from xtrack.prebuild_kernels import regenerate_kernels @@ -55,7 +56,9 @@ def test_prebuild_kernels(mocker, tmp_path): cffi_compile = mocker.patch.object(cffi.FFI, 'compile') line = xt.Line(elements=[xt.Drift(length=2.0)]) - line.build_tracker() + + # Build the tracker on a fresh context, so that the kernel comes from a file + line.build_tracker(_context=xo.ContextCpu()) p = xp.Particles(p0c=1e9, px=3e-6) line.track(p)