From 17bd2c8ecd0f7483675f2c27236d1d52b3901798 Mon Sep 17 00:00:00 2001 From: Pramod Kumbhar Date: Fri, 9 Feb 2024 08:25:16 +0100 Subject: [PATCH] Provide NMODL binary path for RANDOM test (#2717) - if NMODL is installed externally, it's not in $PATH and hence test_nmodlrandom_syntax.py was failing (see BlueBrain/nmodl/pull/1150) - provide the path NMODL binary from CMake to avoid this issue --- CMakeLists.txt | 1 + src/coreneuron/CMakeLists.txt | 2 +- test/CMakeLists.txt | 6 ++++-- test/coreneuron/test_nmodlrandom_syntax.py | 5 ++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c35b8507fd..85dc3cd3d6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,6 +521,7 @@ if(NRN_ENABLE_CORENEURON) get_property(CORENRN_LIB_LINK_FLAGS GLOBAL PROPERTY CORENRN_LIB_LINK_FLAGS) get_property(CORENRN_NEURON_LINK_FLAGS GLOBAL PROPERTY CORENRN_NEURON_LINK_FLAGS) get_property(CORENRN_ENABLE_SHARED GLOBAL PROPERTY CORENRN_ENABLE_SHARED) + get_property(CORENRN_NMODL_BINARY GLOBAL PROPERTY CORENRN_NMODL_BINARY) # NEURON tests that link against CoreNEURON need to depend on it. set(CORENEURON_TARGET_TO_DEPEND coreneuron-for-tests) diff --git a/src/coreneuron/CMakeLists.txt b/src/coreneuron/CMakeLists.txt index 2552c80abd..561b9896e3 100644 --- a/src/coreneuron/CMakeLists.txt +++ b/src/coreneuron/CMakeLists.txt @@ -283,8 +283,8 @@ else() FILES ${NMODL_PROJECT_BINARY_DIR}/share/nmodl/nrnunits.lib DESTINATION share/nmodl COMPONENT nrnunits) - endif() +set_property(GLOBAL PROPERTY CORENRN_NMODL_BINARY "${CORENRN_NMODL_BINARY}") # set correct arguments for nmodl for cpu/gpu target set(CORENRN_NMODL_FLAGS diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c1e5411f03..86d011562b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -655,8 +655,10 @@ if(NRN_ENABLE_PYTHON) NAME test_nmodlrandom_syntax_py_${processor} REQUIRES coreneuron ${processor} ${modtests_preload_sanitizer} SCRIPT_PATTERNS test/coreneuron/test_nmodlrandom_syntax.py - ENVIRONMENT ${modtests_processor_env} ${nrnpython_mpi_env} - COVERAGE_FILE=.coverage.coreneuron_test_nmodlrandom_syntax_py + ENVIRONMENT + ${modtests_processor_env} ${nrnpython_mpi_env} + COVERAGE_FILE=.coverage.coreneuron_test_nmodlrandom_syntax_py + NMODL_BINARY=${CORENRN_NMODL_BINARY} COMMAND ${modtests_launch_py} test/coreneuron/test_nmodlrandom_syntax.py) nrn_add_test( GROUP coreneuron_modtests diff --git a/test/coreneuron/test_nmodlrandom_syntax.py b/test/coreneuron/test_nmodlrandom_syntax.py index 1dbe14ec61..9e04092a7b 100644 --- a/test/coreneuron/test_nmodlrandom_syntax.py +++ b/test/coreneuron/test_nmodlrandom_syntax.py @@ -1,6 +1,7 @@ from neuron import h import subprocess from pathlib import Path +import os # default args generate accepted nmodl string @@ -75,7 +76,9 @@ def chk_nmodl(txt, program="nocmodl", rcode=False): def test_syntax(): - for program in ["nocmodl", "nmodl"]: + # nmodl could be external installation (not in PATH) + nmodl_binary = os.environ.get("NMODL_BINARY", "nmodl") + for program in ["nocmodl", nmodl_binary]: foo = False assert chk_nmodl(modfile(), program, rcode=True) assert chk_nmodl(modfile(s0="ASSIGNED{rv1}"), program)