Giter Site home page Giter Site logo

Comments (2)

bkmgit avatar bkmgit commented on June 20, 2024

Got this to run, though needed to call nihtest through a bash script, could not do it through CMake directly, though maybe there is a better way to do this. Updated CMakeLists.txt

cmake_minimum_required(VERSION 3.12)

# Also update version in nihtest/__main__.py and pyproject.toml
project(nihtest
        VERSION 1.1.0
        DESCRIPTION "NiH testing framework"
        HOMEPAGE_URL "https://github.com/nih-at/nihtest"
        LANGUAGES C)

enable_testing()

find_package(Python3 REQUIRED COMPONENTS Interpreter)

#set(VENV ${CMAKE_BINARY_DIR}/venv)
if (WIN32)
    #set(VENV_BIN_DIR ${VENV}/Scripts)
    #set(VENV_PYTHON ${VENV_BIN_DIR}/python.exe)
else ()  # assume Linux
    #set(VENV_BIN_DIR ${VENV}/bin)
    #set(VENV_PYTHON ${VENV_BIN_DIR}/python)
endif ()

#set(NIHTEST ${VENV_BIN_DIR}/nihtest)

file(GLOB SOURCES ${CMAKE_SOURCE_DIR}/nihtest/*.py)

#add_custom_command(
        #OUTPUT ${NIHTEST}
        #COMMAND ${Python3_EXECUTABLE} -m venv ${VENV}
        #COMMAND ${VENV_BIN_DIR}/pip install -q --disable-pip-version-check ${CMAKE_SOURCE_DIR}
        #DEPENDS ${SOURCES}
#)

#add_custom_target(venv ALL #DEPENDS ${NIHTEST})

# TODO: target for wheel

add_subdirectory(tests)

Updated tests/CMakeLists.txt

cmake_minimum_required(VERSION 3.12)

project(nihtest
        VERSION 0.1.0
        DESCRIPTION "NiH testing framework"
        HOMEPAGE_URL "https://github.com/nih-at/nihtest"
        LANGUAGES C)

set(TEST_PROGRAMS
  can-preload
  comparator
  false
  true
  echo
  cat
  getenv
  file
)

foreach(PROGRAM ${TEST_PROGRAMS})
  add_executable(nihtest-${PROGRAM} ${PROGRAM}.c)
endforeach()

ADD_LIBRARY(ineffective-remove MODULE ineffective-remove.c)
TARGET_LINK_LIBRARIES(ineffective-remove ${CMAKE_DL_LIBS})

# Tests for helper programs
add_test(NAME true COMMAND nihtest-true)
add_test(NAME false COMMAND nihtest-false)
set_tests_properties(false PROPERTIES WILL_FAIL TRUE)
add_test(NAME echo COMMAND nihtest-echo "This test was successful.")
set_tests_properties(echo PROPERTIES PASS_REGULAR_EXPRESSION "This test was successful.")
add_test(NAME cat COMMAND nihtest-cat ${CMAKE_CURRENT_SOURCE_DIR}/success.txt)
set_tests_properties(cat PROPERTIES PASS_REGULAR_EXPRESSION "This is a successful test.")
add_test(NAME getenv-defined COMMAND nihtest-getenv "DEFINED")
set_tests_properties(getenv-defined PROPERTIES ENVIRONMENT DEFINED="This is a successful test.")
set_tests_properties(getenv-defined PROPERTIES PASS_REGULAR_EXPRESSION "DEFINED=\"This is a successful test.\"")
add_test(NAME getenv-undefined COMMAND nihtest-getenv "UNDEFINED")
set_tests_properties(getenv-undefined PROPERTIES PASS_REGULAR_EXPRESSION "UNDEFINED=<null>")

file(GLOB TESTS ${CMAKE_CURRENT_SOURCE_DIR}/*.test)
foreach(FULL_CASE IN LISTS TESTS)
  get_filename_component(CASE ${FULL_CASE} NAME)
  add_test(NAME ${CASE} COMMAND bash /builddir/build/BUILD/nihtest-1.1.0/check.sh ${CASE})
  set_tests_properties(${CASE} PROPERTIES SKIP_RETURN_CODE 77)
  #  set_tests_properties(${CASE} PROPERTIES ENVIRONMENT "PYTHONPATH=/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages:/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib/python3.12/site-packages:$ENV{PYTHONPATH}")
endforeach()

# for testing the "features" keyword
set(HAVE_TEST_EXISTING_FEATURE 1)
set(HAVE_TEST_MISSING_FEATURE 0)

configure_file(nihtest.conf.in ${CMAKE_CURRENT_BINARY_DIR}/nihtest.conf @ONLY) # for *.tests
configure_file(nihtest-conf.in ${CMAKE_CURRENT_BINARY_DIR}/nihtest-conf @ONLY) # for *.input

enable_testing()

# TODO: testing depends on venv

Updated tests/nihtest.conf.in

[settings]
features-files = @PROJECT_BINARY_DIR@/config.h
test-input-directories = @CMAKE_CURRENT_SOURCE_DIR@
program-directories = @PROJECT_BINARY_DIR@
    @VENV_BIN_DIR@

[environment]
PYTHONPATH=/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages:/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib/python3.12/site-packages

check.sh

PATH=/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/bin:/builddir/.local/bin:/builddir/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin PYTHONPATH=/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib64/python3.12/site-packages:/builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/lib/python3.12/site-packages: /usr/bin/python3 /builddir/build/BUILDROOT/python-nihtest-1.1.0-1.fc39.x86_64/usr/bin/nihtest -v $1 

from nihtest.

dillof avatar dillof commented on June 20, 2024

Glad you could solve your problem.

from nihtest.

Related Issues (5)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.