Skip to content

Commit

Permalink
Address pytest root dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Ozaq committed Oct 14, 2024
1 parent 368901c commit fd3731e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
16 changes: 13 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ if (HAVE_GRIBJUMP_LOCAL_EXTRACT)
endif()

# python api test are currently by default disabled because we cannot run them in the ci
ecbuild_add_option(
ecbuild_add_option(
FEATURE PYTHON_API_TESTS
DEFAULT OFF
DESCRIPTION "Will execute python tests against pygribjump / libgribjump")
Expand Down Expand Up @@ -90,10 +90,20 @@ if(HAVE_PYTHON_API_TESTS)
find_python_module(setuptools)
find_python_module(findlibs)

set(FDB5_DIR "${fdb5_DIR}/../../..")
# Prepare to export FDB5_DIR so that findlibs does find our depenant libfdb for pyfdb
# In case we build gribjump standalone, this code relies on the location
# provided by the find module, i.e. fdb5_DIR.
# If this code is build as a bundle, aka a subproject we need to point
# findlib to the folder containing the CMAKE_LIBRARY_OUTPUT_DIRECTORY
if(fdb5_DIR)
set(FDB5_DIR "${fdb5_DIR}/../../..")
else()
set(FDB5_DIR "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/..")
endif()

configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/run_pytest.sh.in
${CMAKE_BINARY_DIR}/run_pytest.sh
${CMAKE_CURRENT_BINARY_DIR}/run_pytest.sh
@ONLY
)

Expand Down
4 changes: 2 additions & 2 deletions cmake/run_pytest.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

export GRIBJUMP_HOME="@CMAKE_BINARY_DIR@"
export FDB5_DIR="@FDB5_DIR@"
export PYTHONPATH="${PYTHONPATH}:@CMAKE_SOURCE_DIR@/pygribjump/src"
export PYTHONPATH="${PYTHONPATH}:@CMAKE_CURRENT_SOURCE_DIR@/pygribjump/src"

@Python_EXECUTABLE@ -m pytest @CMAKE_SOURCE_DIR@ --basetemp="@CMAKE_BINARY_DIR@/test-results" "$@"
@Python_EXECUTABLE@ -m pytest @CMAKE_CURRENT_SOURCE_DIR@ --basetemp="@CMAKE_CURRENT_BINARY_DIR@/test-results" "$@"

6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[tool.pytest.ini_options]
minversion = "6.0"
addopts = "-vv -s"
testpaths = [
"pygribjump/tests"
]

0 comments on commit fd3731e

Please sign in to comment.