thrift/compiler/cpp/tests
Jens Geyer 56700e469d THRIFT-4982 Remove deprecated C# bindings from the code base
Client: csharp
Patch: Jens Geyer

This closes #2027
2020-02-28 19:18:34 +01:00
..
catch THRIFT-4434: .NET Core cleanup and the beginnings of compiler unit tests 2018-01-14 08:39:32 -05:00
netcore THRIFT-4981 Remove deprecated netcore bindings from the code base 2019-10-20 16:21:29 +02:00
CMakeLists.txt THRIFT-4982 Remove deprecated C# bindings from the code base 2020-02-28 19:18:34 +01:00
README.md THRIFT-4981 Remove deprecated netcore bindings from the code base 2019-10-20 16:21:29 +02:00
tests_main.cc THRIFT-4434: .NET Core cleanup and the beginnings of compiler unit tests 2018-01-14 08:39:32 -05:00

Build and run compiler tests using CMake

General information

Added generic way to cover code by tests for many languages (you just need to make a correct header file for generator for your language - example in netstd implementation)

At current moment these tests use free Catch library (https://github.com/catchorg/Catch2/tree/Catch1.x) for easy test creation and usage. Decision to use it was because of simplicity, easy usage, one header file to use, stable community and growing interest (https://cpp.libhunt.com/project/googletest-google/vs/catch?rel=cmp-cmp)

Also, maybe, later it will be migrated to Catch2 (https://github.com/philsquared/Catch) - depends on need to support legacy compilers (c++98)

How to add your tests

  • Open CMakeLists.txt
  • Set On to call of THRIFT_ADD_COMPILER for your language
THRIFT_ADD_COMPILER(netstd "Enable compiler for .NET Standard" ON)
  • Create folder with name specified in list of languages in CMakeLists.txt

  • Create tests in folder for your language (with extensions like .c - cc, cpp, etc)

    • Don't forget to add include of catch.hpp in your test file
    #include "../catch/catch.hpp"
    
  • If you need - add files manually to thrift_compiler_tests_manual_SOURCES in CMakeLists.txt similar to

# you can add some files manually there 
set(thrift_compiler_tests_manual_SOURCES
    # tests file to avoid main in every test file
    ${CMAKE_CURRENT_SOURCE_DIR}/tests_main.cc
)
  • Run cmake with arguments for your environment and compiler
  • Enjoy

Build and run tests on Unix-like systems

Prerequisites:

Build and run test with CMake

  • Run commands in command line in current directory:
mkdir cmake-vs && cd cmake-vs
cmake ..
cmake --build .
ctest -C Debug -V

Build and run tests on Windows

Prerequisites:

Generation of VS project with CMake, build and run on Windows

  • Run commands in command line in current directory (ensure that VS installed):
mkdir cmake-vs
cd cmake-vs
cmake ..
cmake --build .
ctest -C Debug -V