From 0f09eb2d621312caa706c4be397238df5c8ba63c Mon Sep 17 00:00:00 2001
From: Andreas Kloeckner <inform@tiker.net>
Date: Tue, 14 Jan 2025 13:49:27 -0600
Subject: [PATCH] Centralize jemalloc logic

---
 ci-support.sh | 28 ++++++++++++++--------------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/ci-support.sh b/ci-support.sh
index cf15100..b6eb308 100644
--- a/ci-support.sh
+++ b/ci-support.sh
@@ -65,6 +65,18 @@ rewrite_pyopencl_test()
 }
 
 
+set_up_jemalloc()
+{
+  CONDA_JEMALLOC="$CONDA_PREFIX/lib/libjemalloc.so.2"
+  if test "$CONDA_PREFIX" != "" && test -f "$CONDA_JEMALLOC"; then
+    # echo "*** running with $CONDA_JEMALLOC in LD_PRELOAD"
+    # CI_SUPPORT_LD_PRELOAD="$CONDA_JEMALLOC"
+    echo "*** $CONDA_JEMALLOC installed, skipping because of crashes observed in January 2025"
+  fi
+  CI_SUPPORT_LD_PRELOAD="$LD_PRELOAD"
+}
+
+
 # {{{ utilities
 
 function tomlsh {
@@ -484,13 +496,7 @@ test_py_project()
     DOCTEST_MODULES_FLAG=""
   fi
 
-  CONDA_JEMALLOC="$CONDA_PREFIX/lib/libjemalloc.so.2"
-  if test "$CONDA_PREFIX" != "" && test -f "$CONDA_JEMALLOC"; then
-    # echo "*** running with $CONDA_JEMALLOC in LD_PRELOAD"
-    # CI_SUPPORT_LD_PRELOAD="$CONDA_JEMALLOC"
-    echo "*** $CONDA_JEMALLOC installed, skipping because of crashes observed in January 2025"
-  fi
-  CI_SUPPORT_LD_PRELOAD="$LD_PRELOAD"
+  set_up_jemalloc
 
   # Core dumps? Sure, take them.
   ulimit -c unlimited || true
@@ -584,13 +590,7 @@ run_examples()
       cwd=$(dirname "$i")
       example_script=$(basename "$i")
 
-      CONDA_JEMALLOC="$CONDA_PREFIX/lib/libjemalloc.so.2"
-      if test "$CONDA_PREFIX" != "" && test -f "$CONDA_JEMALLOC"; then
-        # echo "*** running with $CONDA_JEMALLOC in LD_PRELOAD"
-        # CI_SUPPORT_LD_PRELOAD="$CONDA_JEMALLOC"
-        echo "*** $CONDA_JEMALLOC installed, skipping because of crashes observed in January 2025"
-      fi
-      CI_SUPPORT_LD_PRELOAD="$LD_PRELOAD"
+      set_up_jemalloc
 
       if [[ $example_script == *mpi* ]]; then
         # FIXME: This command line is OpenMPI-specific.)
-- 
GitLab