Skip to content
This repository has been archived by the owner on Nov 21, 2024. It is now read-only.

Commit

Permalink
Add optional test executable and enable Substrait C API tests (#4)
Browse files Browse the repository at this point in the history
- Added an option `ENABLE_TEST_EXE` to build an optional test executable in `test/c/CMakeLists.txt`.
- Created a new `main.cpp` file to run C tests.
- Updated `test_substrait_c_api.cpp` to fix build errors and remove unused includes.
- Included the new test directory in the main `CMakeLists.txt`.

Co-authored-by: Anshul Data <[email protected]>
  • Loading branch information
scgkiran and anshuldata authored Sep 26, 2024
1 parent be71387 commit 9a3deee
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 5 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
8 changes: 8 additions & 0 deletions test/c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,11 @@ add_library_unity(test_substrait OBJECT ${ALL_SOURCES})
set(ALL_OBJECT_FILES
${ALL_OBJECT_FILES} $<TARGET_OBJECTS:test_substrait>
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 $<TARGET_OBJECTS:test_substrait> main.cpp)
# Link the executable with necessary libraries
target_link_libraries(test_substrait_exe duckdb substrait_extension test_helpers)
endif()
7 changes: 7 additions & 0 deletions test/c/main.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
5 changes: 0 additions & 5 deletions test/c/test_substrait_c_api.cpp
Original file line number Diff line number Diff line change
@@ -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 <chrono>
#include <thread>
Expand All @@ -13,7 +10,6 @@ using namespace std;

TEST_CASE("Test C Get and To Substrait API", "[substrait-api]") {
DuckDB db(nullptr);
db.LoadExtension<duckdb::DUCKDB_EXTENSION_CLASS>();
Connection con(db);
con.EnableQueryVerification();
// create the database
Expand All @@ -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<duckdb::DUCKDB_EXTENSION_CLASS>();
Connection con(db);
con.EnableQueryVerification();
// create the database
Expand Down

0 comments on commit 9a3deee

Please sign in to comment.