File: README.md

package info (click to toggle)
thrift 0.22.0-3
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 29,588 kB
  • sloc: cpp: 103,295; java: 26,996; ansic: 21,793; pascal: 15,437; php: 12,823; cs: 10,610; python: 9,733; javascript: 9,274; ruby: 8,316; erlang: 7,360; sh: 5,569; makefile: 4,203; perl: 3,351; yacc: 1,145; xml: 1,079; ml: 962; lisp: 664; lex: 322
file content (88 lines) | stat: -rw-r--r-- 3,185 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Build and run compiler tests using CMake

<!-- TOC -->

- [Build and run compiler tests using CMake](#build-and-run-compiler-tests-using-cmake)
    - [General information](#general-information)
    - [How to add your tests](#how-to-add-your-tests)
    - [Build and run tests on Unix-like systems](#build-and-run-tests-on-unix-like-systems)
        - [Prerequisites:](#prerequisites)
        - [Build and run test with CMake](#build-and-run-test-with-cmake)
    - [Build and run tests on Windows](#build-and-run-tests-on-windows)
        - [Prerequisites:](#prerequisites-1)
        - [Generation of VS project with CMake, build and run on Windows](#generation-of-vs-project-with-cmake-build-and-run-on-windows)

<!-- /TOC -->

## 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 call of `THRIFT_ADD_COMPILER` for your language to `ON`

``` cmake 
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
  ``` C
  #include "../catch/catch.hpp"
  ```

- If you need - add files manually to **thrift_compiler_tests_manual_SOURCES** in **CMakeLists.txt** similar to 

``` cmake
# 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:
- Install CMake - <https://cmake.org/download/>
- Install winflexbison - <https://sourceforge.net/projects/winflexbison/>

### 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:
- Install CMake - <https://cmake.org/download/>
- Install winflexbison - <https://sourceforge.net/projects/winflexbison/>
- Install VS2017 Community Edition - <https://www.visualstudio.com/vs/whatsnew/> (ensure that you installed workload "Desktop Development with C++" for VS2017)

### 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
```