diff --git a/CMakeLists.txt b/CMakeLists.txt index f180c46..380385c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -107,6 +107,7 @@ add_library(${EXTENSION_NAME} STATIC ${EXTENSION_SOURCES}) set(PARAMETERS "-warnings") build_loadable_extension(${TARGET_NAME} ${PARAMETERS} ${EXTENSION_SOURCES}) +add_subdirectory("test/c") install( TARGETS ${EXTENSION_NAME} diff --git a/test/c/CMakeLists.txt b/test/c/CMakeLists.txt index e84f702..d0e60e4 100644 --- a/test/c/CMakeLists.txt +++ b/test/c/CMakeLists.txt @@ -19,3 +19,11 @@ add_library_unity(test_substrait OBJECT ${ALL_SOURCES}) set(ALL_OBJECT_FILES ${ALL_OBJECT_FILES} $ PARENT_SCOPE) + +option(ENABLE_TEST_EXE "Build the optional test executable" OFF) +if (ENABLE_TEST_EXE) + # Add an executable target with main.cpp + add_executable(test_substrait_exe $ main.cpp) + # Link the executable with necessary libraries + target_link_libraries(test_substrait_exe duckdb substrait_extension test_helpers) +endif() diff --git a/test/c/main.cpp b/test/c/main.cpp new file mode 100644 index 0000000..4aeef60 --- /dev/null +++ b/test/c/main.cpp @@ -0,0 +1,7 @@ +#define CATCH_CONFIG_RUNNER +#include "catch.hpp" + +int main(int argc, char* argv[]) { + // Call Catch2's session to run tests + return Catch::Session().run(argc, argv); +} diff --git a/test/c/test_substrait_c_api.cpp b/test/c/test_substrait_c_api.cpp index 3f97646..fe79d65 100644 --- a/test/c/test_substrait_c_api.cpp +++ b/test/c/test_substrait_c_api.cpp @@ -1,9 +1,6 @@ #include "catch.hpp" #include "test_helpers.hpp" -#include "duckdb/parser/parser.hpp" -#include "duckdb/planner/logical_operator.hpp" #include "duckdb/main/connection_manager.hpp" -#include "substrait_extension.hpp" #include #include @@ -13,7 +10,6 @@ using namespace std; TEST_CASE("Test C Get and To Substrait API", "[substrait-api]") { DuckDB db(nullptr); - db.LoadExtension(); Connection con(db); con.EnableQueryVerification(); // create the database @@ -33,7 +29,6 @@ TEST_CASE("Test C Get and To Substrait API", "[substrait-api]") { TEST_CASE("Test C Get and To Json-Substrait API", "[substrait-api]") { DuckDB db(nullptr); - db.LoadExtension(); Connection con(db); con.EnableQueryVerification(); // create the database