File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- [submodule "lib/concurrentqueue "]
2- path = lib/concurrentqueue
3- url = https://github.com/cameron314/concurrentqueue.git
4- [submodule "lib/dlpack "]
5- path = lib/dlpack
6- url = https://github.com/dmlc/dlpack.git
7- [submodule "lib/pybind11 "]
8- path = lib/pybind11
9- url = https://github.com/pybind/pybind11.git
1+ [submodule "extern/Catch2 "]
2+ path = extern/Catch2
3+ url = https://github.com/catchorg/Catch2.git
Original file line number Diff line number Diff line change @@ -24,6 +24,14 @@ if(BUILD_EXAMPLES)
2424 add_subdirectory (examples )
2525endif ()
2626
27+ # Build test cases
28+ option (BUILD_TESTS "Build test cases" OFF )
29+ if (BUILD_TESTS)
30+ add_subdirectory (extern/Catch2 )
31+ enable_testing ()
32+ add_subdirectory (tests )
33+ endif ()
34+
2735# Install
2836include (GNUInstallDirs )
2937include (CMakePackageConfigHelpers )
Original file line number Diff line number Diff line change 66BUILD_TYPE=" Debug"
77BUILD_DIR=" build"
88BUILD_EXAMPLES=OFF
9+ BUILD_TESTS=OFF
910
1011# Parse arguments
1112while [[ " $# " -gt 0 ]]; do
1213 case $1 in
13- -t | --type )
14+ -m | --mode )
1415 BUILD_TYPE=" $2 "
1516 shift
1617 ;;
@@ -21,11 +22,15 @@ while [[ "$#" -gt 0 ]]; do
2122 -e | --examples)
2223 BUILD_EXAMPLES=ON
2324 ;;
25+ -t | --tests)
26+ BUILD_TESTS=ON
27+ ;;
2428 -h | --help)
2529 echo " Usage: ./configure.sh [-t Debug|Release|RelWithDebInfo|MinSizeRel] [-d build_dir] [-e]"
26- echo " -t | --type : Build type (default: Debug)"
30+ echo " -m | --mode : Build type (default: Debug)"
2731 echo " -d | --dir : Build directory (default: build)"
28- echo " -e | --examples : Enable building examples"
32+ echo " -e | --examples : Enable building examples (default: OFF)"
33+ echo " -t | --tests : Enable building tests (default: OFF)"
2934 exit 0
3035 ;;
3136 * )
@@ -40,11 +45,16 @@ echo "Configuring project..."
4045echo " Build type : $BUILD_TYPE "
4146echo " Build dir : $BUILD_DIR "
4247echo " Build examples : $BUILD_EXAMPLES "
48+ echo " Build tests : $BUILD_TESTS "
4349
4450# Create build directory
4551mkdir -p " $BUILD_DIR "
4652
4753# Run CMake configuration
48- cmake -B " $BUILD_DIR " -DCMAKE_BUILD_TYPE=" $BUILD_TYPE " -DBUILD_EXAMPLES=" $BUILD_EXAMPLES " -S .
54+ cmake -B " $BUILD_DIR " \
55+ -DCMAKE_BUILD_TYPE=" $BUILD_TYPE " \
56+ -DBUILD_EXAMPLES=" $BUILD_EXAMPLES " \
57+ -DBUILD_TESTS=" $BUILD_TESTS " \
58+ -S .
4959
5060echo " Configuration complete. You can now run: cmake --build $BUILD_DIR "
Original file line number Diff line number Diff line change 1+ file (GLOB TEST_SOURCES CONFIGURE_DEPENDS *.cpp )
2+
3+ get_target_property (_inc Catch2::Catch2WithMain INTERFACE_INCLUDE_DIRECTORIES )
4+ message (STATUS "Catch2::Catch2WithMain include dirs: ${_inc} " )
5+
6+
7+ add_executable (pyscheduler_tests ${TEST_SOURCES} )
8+ target_link_libraries (pyscheduler_tests PRIVATE pyscheduler Catch2::Catch2WithMain )
9+
10+ include (CTest )
11+ include (Catch )
12+ catch_discover_tests (pyscheduler_tests )
Original file line number Diff line number Diff line change 1+ #include " pyscheduler/pyscheduler.hpp"
2+ #include < catch2/catch_all.hpp>
3+
4+ using namespace pyscheduler ;
5+
6+ static PyManager manager;
7+
8+ TEST_CASE (" Load Standard Module" , " [basic]" ) {
9+ PyManager::InvokeHandler reflect = manager.getPythonModule (" tests.test_modules.reflect" );
10+ }
11+
12+ TEST_CASE (" Reflect Test" , " [basic]" ) {
13+ PyManager::InvokeHandler reflect = manager.getPythonModule (" tests.test_modules.reflect" );
14+
15+ REQUIRE (reflect.invoke <std::string>(" hello" ) == " hello" );
16+ REQUIRE (reflect.invoke <double >(3.1415926535 ) == 3.1415926535 );
17+ }
Original file line number Diff line number Diff line change 1+ def invoke (x ):
2+ return x
You can’t perform that action at this time.
0 commit comments