Skip to content

Commit

Permalink
[C++ comm] Rephrase unit tests to match core.
Browse files Browse the repository at this point in the history
Closes #319
  • Loading branch information
Ted Stein committed Feb 6, 2017
1 parent c454732 commit f499596
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 75 deletions.
117 changes: 54 additions & 63 deletions cpp/test/comm/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,74 +1,65 @@
if (MSVC)
add_bond_test (unit_test_comm
unit_test_comm.cpp
unit_test_comm.bond
unit_test_comm_async.cpp
unit_test_comm_basic.cpp
unit_test_comm_core.cpp
unit_test_comm_error.cpp
unit_test_comm_event.bond
unit_test_comm_event.cpp
unit_test_comm_forward.cpp
unit_test_comm_generic.bond
unit_test_comm_generic_type.cpp
unit_test_comm_generic_service.cpp
unit_test_comm_jumbo.cpp
unit_test_comm_layers.cpp
unit_test_comm_protocol.cpp
unit_test_comm_session.bond
unit_test_comm_session.cpp
unit_test_comm_timeout.cpp
unit_test_comm_unexpected.cpp
unit_test_comm_utils.bond
unit_test_comm_utils.cpp
unit_test_comm_void.bond
unit_test_comm_void.cpp
COMM)
else()
add_bond_test (unit_test_comm
unit_test_comm.cpp
unit_test_comm.bond
unit_test_comm_async.cpp
unit_test_comm_basic.cpp
unit_test_comm_core.cpp
unit_test_comm_error.cpp
unit_test_comm_event.bond
unit_test_comm_event.cpp
unit_test_comm_forward.cpp
unit_test_comm_generic.bond
unit_test_comm_generic_type.cpp
unit_test_comm_generic_service.cpp
unit_test_comm_jumbo.cpp
unit_test_comm_layers.cpp
unit_test_comm_protocol.cpp
unit_test_comm_session.bond
unit_test_comm_session.cpp
unit_test_comm_timeout.cpp
unit_test_comm_unexpected.cpp
unit_test_comm_utils.bond
unit_test_comm_utils.cpp
unit_test_comm_void.bond
unit_test_comm_void.cpp
COMM
BUILD_ONLY)
endif()
# To add a new unit test suite, call add_unit_test at the bottom of this file on
# all of the files you want built into your test suite. The name of the suite
# will be derived from the name of the file that is given first.
function (add_unit_test)
get_filename_component(name ${ARGV0} NAME_WE)
set (files ${ARGV})
add_bond_test (${name} EXCLUDE_FROM_ALL ${files} COMM)
add_target_to_folder (${name})
add_dependencies (${name}
bond
comm_test_codegen)
target_include_directories (${name} PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
target_compile_definitions (${name} PUBLIC
-DBOND_COMPACT_BINARY_PROTOCOL
-DBOND_SIMPLE_BINARY_PROTOCOL
-DBOND_FAST_BINARY_PROTOCOL)
target_link_libraries (${name} PRIVATE
bond
comm_test_common
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${Boost_CHRONO_LIBRARY})

cxx_target_compile_options (MSVC ${name} PRIVATE -D_WIN32_WINNT=0x0600)

cxx_target_compile_options (Clang ${name} PRIVATE -DBOOST_ASIO_HAS_STD_CHRONO)
cxx_target_compile_options (AppleClang ${name} PRIVATE -DBOOST_ASIO_HAS_STD_CHRONO)
endfunction()

# TODO: needed for lock, should be abstracted away in platform specific stuff
target_compile_definitions (unit_test_comm PRIVATE -D_WIN32_WINNT=0x0600)

# Build common code into its own library.
add_library (comm_test_common EXCLUDE_FROM_ALL "main.cpp")
add_library (comm_test_common EXCLUDE_FROM_ALL "main.cpp" "idl.cpp")
add_target_to_folder (comm_test_common)
add_dependencies(comm_test_common comm_test_codegen)
target_include_directories (comm_test_common PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
target_link_libraries (comm_test_common PRIVATE
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})

cxx_target_compile_options (Clang unit_test_comm PRIVATE -DBOOST_ASIO_HAS_STD_CHRONO)
cxx_target_compile_options (AppleClang unit_test_comm PRIVATE -DBOOST_ASIO_HAS_STD_CHRONO)
add_bond_codegen (TARGET comm_test_codegen unit_test_comm.bond COMM)

target_link_libraries (unit_test_comm PRIVATE
comm_test_common
${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}
${Boost_CHRONO_LIBRARY})
add_unit_test (unit_test_comm.cpp
unit_test_comm_async.cpp
unit_test_comm_basic.cpp
unit_test_comm_core.cpp
unit_test_comm_error.cpp
unit_test_comm_event.bond
unit_test_comm_event.cpp
unit_test_comm_forward.cpp
unit_test_comm_generic.bond
unit_test_comm_generic_type.cpp
unit_test_comm_generic_service.cpp
unit_test_comm_jumbo.cpp
unit_test_comm_layers.cpp
unit_test_comm_protocol.cpp
unit_test_comm_session.bond
unit_test_comm_session.cpp
unit_test_comm_timeout.cpp
unit_test_comm_unexpected.cpp
unit_test_comm_utils.bond
unit_test_comm_utils.cpp
unit_test_comm_void.bond
unit_test_comm_void.cpp)
3 changes: 3 additions & 0 deletions cpp/test/comm/idl.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "unit_test_comm_apply.cpp"
#include "unit_test_comm_comm.cpp"
#include "unit_test_comm_types.cpp"
24 changes: 12 additions & 12 deletions cpp/test/core/idl.cpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#include <unit_test_types.cpp>
#include <unit_test_core_types.cpp>
#include <allocator_test_types.cpp>
#include <import_test1_types.cpp>
#include <import_test1_apply.cpp>
#include <import_test2_types.cpp>
#include <apply_test_types.cpp>
#include <apply_test_apply.cpp>
#include <validation_types.cpp>
#include <scope_test1_types.cpp>
#include <scope_test2_types.cpp>
#include <cmdargs_types.cpp>
#include "unit_test_types.cpp"
#include "unit_test_core_types.cpp"
#include "allocator_test_types.cpp"
#include "import_test1_types.cpp"
#include "import_test1_apply.cpp"
#include "import_test2_types.cpp"
#include "apply_test_types.cpp"
#include "apply_test_apply.cpp"
#include "validation_types.cpp"
#include "scope_test1_types.cpp"
#include "scope_test2_types.cpp"
#include "cmdargs_types.cpp"

#ifndef ENABLE_TEST_CASE
# include "unit_test_core_apply.cpp"
Expand Down

0 comments on commit f499596

Please sign in to comment.