2016-12-16 21:05:04 +08:00
|
|
|
# set current directory name as a test type
|
|
|
|
get_filename_component(test_type ${CMAKE_CURRENT_SOURCE_DIR} NAME)
|
|
|
|
|
|
|
|
# get all cpp abs file names recursively starting from current directory
|
|
|
|
file(GLOB_RECURSE test_type_cpps *.cpp)
|
|
|
|
message(STATUS "Available ${test_type} cpp files are: ${test_type_cpps}")
|
|
|
|
|
|
|
|
# for each cpp file build binary and register test
|
|
|
|
foreach(test_cpp ${test_type_cpps})
|
|
|
|
|
|
|
|
# get exec name (remove extension from the abs path)
|
|
|
|
get_filename_component(exec_name ${test_cpp} NAME_WE)
|
|
|
|
|
2017-10-06 19:10:31 +08:00
|
|
|
set(target_name memgraph__${test_type}__${exec_name})
|
2016-12-16 21:05:04 +08:00
|
|
|
|
|
|
|
# build exec file
|
|
|
|
add_executable(${target_name} ${test_cpp})
|
|
|
|
|
|
|
|
# OUTPUT_NAME sets the real name of a target when it is built and can be
|
|
|
|
# used to help create two targets of the same name even though CMake
|
|
|
|
# requires unique logical target names
|
|
|
|
set_target_properties(${target_name} PROPERTIES OUTPUT_NAME ${exec_name})
|
|
|
|
|
|
|
|
# link libraries
|
Split GraphDb to distributed and single node files
Summary:
This change, hopefully, simplifies the implementation of different kinds
of GraphDb. The pimpl idiom is now simplified by removing all of the
crazy inheritance. Implementations classes are just plain data stores,
without any methods. The interface classes now have a more flat
hierarchy:
```
GraphDb (pure interface)
|
+----+---------- DistributedGraphDb (pure interface)
| |
Single Node +-----+------+
| |
Master Worker
```
DistributedGraphDb is used as an intermediate interface for all the
things that should work only in distributed. Therefore, virtual calls
for distributed stuff have been removed from GraphDb. Some are exposed
via DistributedGraphDb, other's are only in concrete Master and Worker
classes. The code which relied on those virtual calls has been
refactored to either use DistributedGraphDb, take a pointer to what is
actually needed or use dynamic_cast. Obviously, dynamic_cast is a
temporary solution and should be replaced with another mechanism (e.g.
virtual call, or some other function pointer style).
The cost of the above change is some code duplication in constructors
and destructors of classes. This duplication has a lot of little tweaks
that make it hard to generalize, not to mention that virtual calls do
not work in constructor and destructor. If we really care about
generalizing this, we should think about abandoning RAII in favor of
constructor + Init method.
The next steps for splitting the dependencies that seem logical are:
1) Split GraphDbAccessor implementation, either via inheritance or
passing in an implementation pointer. GraphDbAccessor should then
only be created by a virtual call on GraphDb.
2) Split Interpreter implementation. Besides allowing single node
interpreter to exist without depending on distributed, this will
enable the planner and operators to be correctly separated.
Reviewers: msantl, mferencevic, ipaljak
Reviewed By: msantl
Subscribers: dgleich, pullbot
Differential Revision: https://phabricator.memgraph.io/D1493
2018-07-19 23:00:50 +08:00
|
|
|
target_link_libraries(${target_name} memgraph_lib mg-integrations kvstore_dummy_lib)
|
2016-12-22 22:51:16 +08:00
|
|
|
# gtest
|
2017-10-03 19:56:41 +08:00
|
|
|
target_link_libraries(${target_name} gtest gmock gtest_main)
|
2016-12-16 21:05:04 +08:00
|
|
|
|
|
|
|
# register test
|
|
|
|
add_test(${target_name} ${exec_name})
|
|
|
|
|
|
|
|
endforeach()
|