Procházet zdrojové kódy

test: prepare plugin stuff

Michele Caini před 6 roky
rodič
revize
4f028d8201

+ 1 - 0
CMakeLists.txt

@@ -161,6 +161,7 @@ if(BUILD_TESTING)
     option(BUILD_BENCHMARK "Build benchmark." OFF)
     option(BUILD_LIB "Build lib example." OFF)
     option(BUILD_MOD "Build mod example." OFF)
+    option(BUILD_PLUGIN "Build plugin example." OFF)
     option(BUILD_SNAPSHOT "Build snapshot example." OFF)
 
     enable_testing()

+ 54 - 38
test/CMakeLists.txt

@@ -39,41 +39,57 @@ endmacro()
 add_library(odr OBJECT odr.cpp)
 SETUP_TARGET(odr)
 
-macro(SETUP_AND_ADD_TEST TEST_NAME TEST_SOURCE)
+macro(SETUP_BASIC_TEST TEST_NAME TEST_SOURCE)
     add_executable(${TEST_NAME} $<TARGET_OBJECTS:odr> ${TEST_SOURCE})
     target_link_libraries(${TEST_NAME} PRIVATE GTest::Main Threads::Threads)
     SETUP_TARGET(${TEST_NAME})
     add_test(NAME ${TEST_NAME} COMMAND ${TEST_NAME})
 endmacro()
 
-macro(SETUP_AND_ADD_LIB_TEST TEST_NAME)
+macro(SETUP_LIB_TEST TEST_NAME)
     add_library(_${TEST_NAME} SHARED lib/${TEST_NAME}/lib.cpp)
     SETUP_TARGET(_${TEST_NAME})
-    SETUP_AND_ADD_TEST(lib_${TEST_NAME} lib/${TEST_NAME}/main.cpp)
+    SETUP_BASIC_TEST(lib_${TEST_NAME} lib/${TEST_NAME}/main.cpp)
     target_link_libraries(lib_${TEST_NAME} PRIVATE _${TEST_NAME})
 endmacro()
 
+macro(SETUP_PLUGIN_TEST TEST_NAME)
+    add_library(_${TEST_NAME}_plugin SHARED plugin/${TEST_NAME}/plugin.cpp)
+    SETUP_TARGET(_${TEST_NAME}_plugin)
+    SETUP_BASIC_TEST(lib_${TEST_NAME}_plugin plugin/${TEST_NAME}/main.cpp)
+    target_compile_definitions(lib_${TEST_NAME}_plugin PRIVATE PLUGIN=$<TARGET_FILE:_${TEST_NAME}_plugin>)
+    target_include_directories(lib_${TEST_NAME}_plugin PRIVATE ${CR_SRC_DIR})
+    target_include_directories(_${TEST_NAME}_plugin PRIVATE ${CR_SRC_DIR})
+endmacro()
+
 # Test benchmark
 
 if(BUILD_BENCHMARK)
-    SETUP_AND_ADD_TEST(benchmark benchmark/benchmark.cpp)
+    SETUP_BASIC_TEST(benchmark benchmark/benchmark.cpp)
 endif()
 
 # Test lib
 
 if(BUILD_LIB)
-    SETUP_AND_ADD_LIB_TEST(dispatcher)
-    SETUP_AND_ADD_LIB_TEST(emitter)
-    SETUP_AND_ADD_LIB_TEST(meta)
-    SETUP_AND_ADD_LIB_TEST(registry)
+    SETUP_LIB_TEST(dispatcher)
+    SETUP_LIB_TEST(emitter)
+    SETUP_LIB_TEST(meta)
+    SETUP_LIB_TEST(registry)
+endif()
+
+# Test plugin
 
+if(BUILD_PLUGIN)
     set(CR_DEPS_DIR ${EnTT_SOURCE_DIR}/deps/cr)
     configure_file(${EnTT_SOURCE_DIR}/cmake/in/cr.in ${CR_DEPS_DIR}/CMakeLists.txt)
     execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . WORKING_DIRECTORY ${CR_DEPS_DIR})
     execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CR_DEPS_DIR})
     set(CR_SRC_DIR ${CR_DEPS_DIR}/src)
 
-    # TODO
+    SETUP_PLUGIN_TEST(dispatcher)
+    SETUP_PLUGIN_TEST(emitter)
+    SETUP_PLUGIN_TEST(meta)
+    SETUP_PLUGIN_TEST(registry)
 endif()
 
 # Test mod
@@ -88,7 +104,7 @@ if(BUILD_MOD)
     set(DUKTAPE_SRC_DIR ${DUKTAPE_DEPS_DIR}/src/src)
 
     set(MOD_TEST_SOURCE ${DUKTAPE_SRC_DIR}/duktape.c mod/mod.cpp)
-    SETUP_AND_ADD_TEST(mod "${MOD_TEST_SOURCE}")
+    SETUP_BASIC_TEST(mod "${MOD_TEST_SOURCE}")
     target_include_directories(mod PRIVATE ${DUKTAPE_SRC_DIR})
 endif()
 
@@ -101,54 +117,54 @@ if(BUILD_SNAPSHOT)
     execute_process(COMMAND ${CMAKE_COMMAND} --build . WORKING_DIRECTORY ${CEREAL_DEPS_DIR})
     set(CEREAL_SRC_DIR ${CEREAL_DEPS_DIR}/src/include)
 
-    SETUP_AND_ADD_TEST(cereal snapshot/snapshot.cpp)
+    SETUP_BASIC_TEST(cereal snapshot/snapshot.cpp)
     target_include_directories(cereal PRIVATE ${CEREAL_SRC_DIR})
 endif()
 
 # Test core
 
-SETUP_AND_ADD_TEST(algorithm entt/core/algorithm.cpp)
-SETUP_AND_ADD_TEST(family entt/core/family.cpp)
-SETUP_AND_ADD_TEST(hashed_string entt/core/hashed_string.cpp)
-SETUP_AND_ADD_TEST(ident entt/core/ident.cpp)
-SETUP_AND_ADD_TEST(monostate entt/core/monostate.cpp)
-SETUP_AND_ADD_TEST(type_traits entt/core/type_traits.cpp)
-SETUP_AND_ADD_TEST(utility entt/core/utility.cpp)
+SETUP_BASIC_TEST(algorithm entt/core/algorithm.cpp)
+SETUP_BASIC_TEST(family entt/core/family.cpp)
+SETUP_BASIC_TEST(hashed_string entt/core/hashed_string.cpp)
+SETUP_BASIC_TEST(ident entt/core/ident.cpp)
+SETUP_BASIC_TEST(monostate entt/core/monostate.cpp)
+SETUP_BASIC_TEST(type_traits entt/core/type_traits.cpp)
+SETUP_BASIC_TEST(utility entt/core/utility.cpp)
 
 # Test entity
 
-SETUP_AND_ADD_TEST(actor entt/entity/actor.cpp)
-SETUP_AND_ADD_TEST(entity entt/entity/entity.cpp)
-SETUP_AND_ADD_TEST(group entt/entity/group.cpp)
-SETUP_AND_ADD_TEST(helper entt/entity/helper.cpp)
-SETUP_AND_ADD_TEST(observer entt/entity/observer.cpp)
-SETUP_AND_ADD_TEST(registry entt/entity/registry.cpp)
-SETUP_AND_ADD_TEST(runtime_view entt/entity/runtime_view.cpp)
-SETUP_AND_ADD_TEST(snapshot entt/entity/snapshot.cpp)
-SETUP_AND_ADD_TEST(sparse_set entt/entity/sparse_set.cpp)
-SETUP_AND_ADD_TEST(storage entt/entity/storage.cpp)
-SETUP_AND_ADD_TEST(view entt/entity/view.cpp)
+SETUP_BASIC_TEST(actor entt/entity/actor.cpp)
+SETUP_BASIC_TEST(entity entt/entity/entity.cpp)
+SETUP_BASIC_TEST(group entt/entity/group.cpp)
+SETUP_BASIC_TEST(helper entt/entity/helper.cpp)
+SETUP_BASIC_TEST(observer entt/entity/observer.cpp)
+SETUP_BASIC_TEST(registry entt/entity/registry.cpp)
+SETUP_BASIC_TEST(runtime_view entt/entity/runtime_view.cpp)
+SETUP_BASIC_TEST(snapshot entt/entity/snapshot.cpp)
+SETUP_BASIC_TEST(sparse_set entt/entity/sparse_set.cpp)
+SETUP_BASIC_TEST(storage entt/entity/storage.cpp)
+SETUP_BASIC_TEST(view entt/entity/view.cpp)
 
 # Test locator
 
-SETUP_AND_ADD_TEST(locator entt/locator/locator.cpp)
+SETUP_BASIC_TEST(locator entt/locator/locator.cpp)
 
 # Test meta
 
-SETUP_AND_ADD_TEST(meta entt/meta/meta.cpp)
+SETUP_BASIC_TEST(meta entt/meta/meta.cpp)
 
 # Test process
 
-SETUP_AND_ADD_TEST(process entt/process/process.cpp)
-SETUP_AND_ADD_TEST(scheduler entt/process/scheduler.cpp)
+SETUP_BASIC_TEST(process entt/process/process.cpp)
+SETUP_BASIC_TEST(scheduler entt/process/scheduler.cpp)
 
 # Test resource
 
-SETUP_AND_ADD_TEST(resource entt/resource/resource.cpp)
+SETUP_BASIC_TEST(resource entt/resource/resource.cpp)
 
 # Test signal
 
-SETUP_AND_ADD_TEST(delegate entt/signal/delegate.cpp)
-SETUP_AND_ADD_TEST(dispatcher entt/signal/dispatcher.cpp)
-SETUP_AND_ADD_TEST(emitter entt/signal/emitter.cpp)
-SETUP_AND_ADD_TEST(sigh entt/signal/sigh.cpp)
+SETUP_BASIC_TEST(delegate entt/signal/delegate.cpp)
+SETUP_BASIC_TEST(dispatcher entt/signal/dispatcher.cpp)
+SETUP_BASIC_TEST(emitter entt/signal/emitter.cpp)
+SETUP_BASIC_TEST(sigh entt/signal/sigh.cpp)

+ 15 - 0
test/plugin/dispatcher/BUILD.bazel

@@ -0,0 +1,15 @@
+load("//bazel:copts.bzl", "entt_copts")
+
+cc_test(
+    name = "lib_dispatcher_plugin",
+    srcs = [
+        "types.h",
+        "plugin.cpp",
+        "main.cpp",
+    ],
+    copts = entt_copts,
+    deps = [
+        "//:entt",
+        "@com_google_googletest//:gtest_main",
+    ],
+)

+ 0 - 0
test/plugin/dispatcher/main.cpp


+ 0 - 0
test/plugin/dispatcher/plugin.cpp


+ 0 - 0
test/plugin/dispatcher/types.h


+ 15 - 0
test/plugin/emitter/BUILD.bazel

@@ -0,0 +1,15 @@
+load("//bazel:copts.bzl", "entt_copts")
+
+cc_test(
+    name = "lib_emitter_plugin",
+    srcs = [
+        "types.h",
+        "plugin.cpp",
+        "main.cpp",
+    ],
+    copts = entt_copts,
+    deps = [
+        "//:entt",
+        "@com_google_googletest//:gtest_main",
+    ],
+)

+ 0 - 0
test/plugin/emitter/main.cpp


+ 0 - 0
test/plugin/emitter/plugin.cpp


+ 0 - 0
test/plugin/emitter/types.h


+ 15 - 0
test/plugin/meta/BUILD.bazel

@@ -0,0 +1,15 @@
+load("//bazel:copts.bzl", "entt_copts")
+
+cc_test(
+    name = "lib_meta_plugin",
+    srcs = [
+        "types.h",
+        "plugin.cpp",
+        "main.cpp",
+    ],
+    copts = entt_copts,
+    deps = [
+        "//:entt",
+        "@com_google_googletest//:gtest_main",
+    ],
+)

+ 0 - 0
test/plugin/meta/main.cpp


+ 0 - 0
test/plugin/meta/plugin.cpp


+ 0 - 0
test/plugin/meta/types.h


+ 15 - 0
test/plugin/registry/BUILD.bazel

@@ -0,0 +1,15 @@
+load("//bazel:copts.bzl", "entt_copts")
+
+cc_test(
+    name = "lib_registry_plugin",
+    srcs = [
+        "types.h",
+        "plugin.cpp",
+        "main.cpp",
+    ],
+    copts = entt_copts,
+    deps = [
+        "//:entt",
+        "@com_google_googletest//:gtest_main",
+    ],
+)

+ 0 - 0
test/plugin/registry/main.cpp


+ 0 - 0
test/plugin/registry/plugin.cpp


+ 0 - 0
test/plugin/registry/types.h