Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate compilation of source and tests #1181

Merged
merged 1 commit into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- run: pip3 install --user -r tools/python_api/requirements_dev.txt

- name: build
run: make release NUM_THREADS=30
run: make benchmark NUM_THREADS=30

- name: benchmark
run: python3 benchmark/benchmark_runner.py --dataset ldbc-sf100 --thread 1
10 changes: 8 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ endif()
if(${ENABLE_UBSAN})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -fno-common -fpermissive")
endif()
option(BUILD_TESTS "Build C++ and Python tests." FALSE)
option(BUILD_BENCHMARK "Build benchmarks." FALSE)

function(link_threads LIBRARY)
if (CMAKE_VERSION VERSION_LESS "3.1")
Expand All @@ -55,7 +57,7 @@ endfunction()
function(add_kuzu_test TEST_NAME)
set(SRCS ${ARGN})
add_executable(${TEST_NAME} ${SRCS})
target_link_libraries(${TEST_NAME} PRIVATE test_helper)
target_link_libraries(${TEST_NAME} PRIVATE test_helper graph_test)
target_include_directories(${TEST_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/test/include)
include(GoogleTest)
gtest_discover_tests(${TEST_NAME})
Expand All @@ -82,5 +84,9 @@ include_directories(third_party/pybind11/include)

add_subdirectory(third_party)
add_subdirectory(src)
add_subdirectory(test)
if (${BUILD_TESTS})
add_subdirectory(test)
elseif (${BUILD_BENCHMARK})
add_subdirectory(test/test_helper)
endif()
add_subdirectory(tools)
27 changes: 23 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
.PHONY: all release debug test clean arrow clean-external clean-all

all: release
.PHONY: release debug test benchmark all debug-all arrow clean clean-external clean-all

GENERATOR=
FORCE_COLOR=
Expand Down Expand Up @@ -46,8 +44,29 @@ debug: arrow
cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Debug ../.. && \
cmake --build . --config Debug -- -j $(NUM_THREADS)

all: arrow
mkdir -p build/release && \
cd build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=TRUE -DBUILD_BENCHMARK=TRUE ../.. && \
cmake --build . --config Release -- -j $(NUM_THREADS)

alldebug: arrow
mkdir -p build/debug && \
cd build/debug && \
cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTS=TRUE -DBUILD_BENCHMARK=TRUE ../.. && \
cmake --build . --config Debug -- -j $(NUM_THREADS)

test: release
benchmark: arrow
mkdir -p build/release && \
cd build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Release -DBUILD_BENCHMARK=TRUE ../.. && \
cmake --build . --config Release -- -j $(NUM_THREADS)

test: arrow
mkdir -p build/release && \
cd build/release && \
cmake $(GENERATOR) $(FORCE_COLOR) $(SANITIZER_FLAG) -DCMAKE_BUILD_TYPE=Release -DBUILD_TESTS=TRUE ../.. && \
cmake --build . --config Release -- -j $(NUM_THREADS)
cd $(ROOT_DIR)/build/release/test && \
ctest

Expand Down
9 changes: 7 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,16 @@ Kùzu is being actively developed at University of Waterloo as a feature-rich an

## Build
To build from source code, Kùzu requires Cmake(>=3.11), Python 3, and a compiler that supports `C++20`.
- Perform a full clean build
- Perform a full clean build without tests and benchmark:
- `make clean && make`
- Run tests (optional)
- Perform a full clean build with tests and benchmark (optional):
- `make clean && make all`
- Run tests (optional):
- `make test`

For development, use `make debug` to build a non-optimized debug version.
To build in parallel, pass `NUM_THREADS` as parameter, e.g., `make NUM_THREADS=8`.

After build, our CLI binary `kuzu_shell` is available under the directory `build/release/tools/shell/`.

## Installation
Expand Down
1 change: 1 addition & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ target_link_libraries(GTest::GTest INTERFACE gmock_main)

enable_testing()
add_subdirectory(test_helper)
add_subdirectory(graph_test)
add_subdirectory(binder)
add_subdirectory(catalog)
add_subdirectory(common)
Expand Down
3 changes: 1 addition & 2 deletions test/binder/binder_error_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using ::testing::Test;
using namespace kuzu::testing;

class BinderErrorTest : public DBTest {
Expand Down
3 changes: 1 addition & 2 deletions test/binder/binder_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using ::testing::Test;
using namespace kuzu::testing;

class BinderTest : public DBTest {
Expand Down
2 changes: 1 addition & 1 deletion test/catalog/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
add_executable(catalog_test catalog_test.cpp)

target_link_libraries(catalog_test PUBLIC test_helper)
target_link_libraries(catalog_test PUBLIC graph_test)

add_test(kuzu_catalog_test catalog_test)
4 changes: 1 addition & 3 deletions test/catalog/catalog_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#include "catalog/catalog.h"
#include "gtest/gtest.h"
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::catalog;

class CatalogTest : public testing::Test {
Expand Down
1 change: 0 additions & 1 deletion test/common/date_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "gtest/gtest.h"

using namespace kuzu::common;
using namespace std;

TEST(DateTests, IsLeapYearTest) {
EXPECT_TRUE(Date::IsLeapYear(2000));
Expand Down
3 changes: 1 addition & 2 deletions test/common/interval_test.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
#include <string>

#include "common/types/types_include.h"
#include "include/gtest/gtest.h"
#include "gtest/gtest.h"

using namespace kuzu::common;
using namespace std;

TEST(IntervalTests, FromCString) {
interval_t result;
Expand Down
3 changes: 1 addition & 2 deletions test/common/time_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include "common/exception.h"
#include "common/types/types_include.h"
#include "include/gtest/gtest.h"
#include "gtest/gtest.h"

using namespace kuzu::common;
using namespace std;

TEST(TimeTests, FromTime) {
// Hour out of range
Expand Down
3 changes: 1 addition & 2 deletions test/common/timestamp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@

#include "common/exception.h"
#include "common/types/types_include.h"
#include "include/gtest/gtest.h"
#include "gtest/gtest.h"

using namespace kuzu::common;
using namespace std;

TEST(TimestampTests, FromDatetime) {
// day is out of range
Expand Down
1 change: 0 additions & 1 deletion test/common/types_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include "gtest/gtest.h"

using namespace kuzu::common;
using namespace std;

TEST(TypesTests, StringToINT64Conversion) {
EXPECT_EQ(2147483648, TypeUtils::TypeUtils::convertToInt64("2147483648"));
Expand Down
5 changes: 1 addition & 4 deletions test/copy/arrow_node_copy_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
#include <iostream>
#include "graph_test/graph_test.h"

#include "test_helper/test_helper.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_dates_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_dos_style_newline_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_fault_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include "common/exception.h"
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace kuzu::testing;
using namespace std;

class CopyFaultTest : public EmptyDBTest {
public:
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_interval_test.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
#include <string>

#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_lists_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "common/type_utils.h"
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_test.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include "common/csv_reader/csv_reader.h"
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::catalog;
using namespace kuzu::storage;
Expand Down
3 changes: 1 addition & 2 deletions test/copy/copy_timestamp_test.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using namespace std;
using namespace kuzu::common;
using namespace kuzu::storage;
using namespace kuzu::testing;
Expand Down
2 changes: 1 addition & 1 deletion test/demo_db/demo_db_test.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "test_helper/test_helper.h"
#include "graph_test/graph_test.h"

using ::testing::Test;
using namespace kuzu::testing;
Expand Down
13 changes: 13 additions & 0 deletions test/graph_test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
add_library(
graph_test
OBJECT
graph_test.cpp)

target_include_directories(
graph_test
PUBLIC
../include/
../../src/include
)

target_link_libraries(graph_test PUBLIC GTest::GTest kuzu)
Loading