summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoronqtam <vik.kirilov@gmail.com>2017-05-15 00:36:22 +0300
committeronqtam <vik.kirilov@gmail.com>2017-05-16 00:22:26 +0300
commit1cfad66abae7dc7ed7f59649eff18f5b212dea0b (patch)
treec1a50af64332f55cdbdabac3e045953636486274
parentc266008dd098715abceb29de83d2cb3cf3c604cd (diff)
- added instructions on how to integrate doctest into your projects
- tiny docs fixes
-rw-r--r--README.md1
-rw-r--r--doc/markdown/benchmarks.md2
-rw-r--r--doc/markdown/build-systems.md72
-rw-r--r--doc/markdown/faq.md4
-rw-r--r--doc/markdown/parameterized-tests.md52
-rw-r--r--doc/markdown/readme.md1
-rw-r--r--doc/markdown/roadmap.md12
-rw-r--r--scripts/release_process.md8
8 files changed, 110 insertions, 42 deletions
diff --git a/README.md b/README.md
index b0566a6..b1e1b72 100644
--- a/README.md
+++ b/README.md
@@ -99,6 +99,7 @@ Usage:
- [Configuration](doc/markdown/configuration.md)
- [String conversions](doc/markdown/stringification.md)
- [FAQ](doc/markdown/faq.md)
+- [Build systems](doc/markdown/build-systems.md)
- [Examples](examples)
Sponsors
diff --git a/doc/markdown/benchmarks.md b/doc/markdown/benchmarks.md
index 29732a7..e74fc96 100644
--- a/doc/markdown/benchmarks.md
+++ b/doc/markdown/benchmarks.md
@@ -18,7 +18,7 @@ Environment used (Intel i7 3770k, 16g RAM):
- Windows 7 - on an SSD
- Ubuntu 17.04 in a VirtualBox VM - on a HDD
-**doctest** version: 1.2.0 (released on 2017.05.14)
+**doctest** version: 1.2.0 (released on 2017.05.15)
[**Catch**](https://github.com/philsquared/Catch) version: 1.9.3 (released on 2017.04.25)
diff --git a/doc/markdown/build-systems.md b/doc/markdown/build-systems.md
new file mode 100644
index 0000000..9b76d18
--- /dev/null
+++ b/doc/markdown/build-systems.md
@@ -0,0 +1,72 @@
+## Build systems
+
+### CMake
+
+- **doctest** is easiest to use as a single file inside your own repository. Then the following minimal example will work:
+
+```cmake
+cmake_minimum_required(VERSION 3.0)
+project(cmake_test)
+
+# Prepare doctest for other targets to use
+add_library(doctest INTERFACE)
+target_include_directories(doctest INTERFACE path/to/doctest)
+
+# Make test executable
+add_executable(tests main.cpp)
+target_link_libraries(tests doctest)
+```
+
+- You can also use the following CMake snippet to automatically fetch the entire **doctest** repository from github and configure it as an external project:
+
+```cmake
+include(ExternalProject)
+find_package(Git REQUIRED)
+
+ExternalProject_Add(
+ doctest
+ PREFIX ${CMAKE_BINARY_DIR}/doctest
+ GIT_REPOSITORY https://github.com/onqtam/doctest.git
+ TIMEOUT 10
+ UPDATE_COMMAND ${GIT_EXECUTABLE} pull
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND ""
+ INSTALL_COMMAND ""
+ LOG_DOWNLOAD ON
+)
+
+# Expose required variable (DOCTEST_INCLUDE_DIR) to parent scope
+ExternalProject_Get_Property(doctest source_dir)
+set(DOCTEST_INCLUDE_DIR ${source_dir}/doctest CACHE INTERNAL "Path to include folder for doctest")
+```
+
+And later you'll be able to use the doctest include directory like this:
+
+```cmake
+# add it globally
+include_directories(${DOCTEST_INCLUDE_DIR})
+
+# or per target
+target_include_directories(my_target PUBLIC ${DOCTEST_INCLUDE_DIR})
+```
+
+- If you have the entire doctest repository available (as a submodule or just as files) you could also include it in your CMake build by using ```add_subdirectory(path/to/doctest)``` and then you could use it like this:
+
+```cmake
+add_executable(my_tests src_1.cpp src_2.cpp ...)
+target_link_libraries(my_tests doctest)
+```
+
+- The ```CMakeLists.txt``` file of the doctest repository has ```install()``` commands so you could also use doctest as a package.
+
+### Package managers
+
+**doctest** is available through the following package managers:
+
+- vcpkg
+- hunter
+- conan
+
+---
+
+[Home](readme.md#reference)
diff --git a/doc/markdown/faq.md b/doc/markdown/faq.md
index af15d92..a64c6d2 100644
--- a/doc/markdown/faq.md
+++ b/doc/markdown/faq.md
@@ -97,10 +97,10 @@ A way to solve this in CMake is to use object libraries instead of static librar
add_library(with_tests OBJECT src_1.cpp src_2.cpp src_3.cpp ...)
add_library(dll SHARED $<TARGET_OBJECTS:with_tests> dll_src_1.cpp ...)
-add_executable(exe $<TARGET_OBJECTS:with_tests> exe_src_1.cpp ......)
+add_executable(exe $<TARGET_OBJECTS:with_tests> exe_src_1.cpp ...)
```
-Thanks to [pthom](https://github.com/pthom) for discovering this.
+Thanks to [pthom](https://github.com/pthom) for suggesting this.
As an alternative I have created a CMake function that forces every object file from a static library to be linked into a binary target - it is called [**```doctest_force_link_static_lib_in_target()```**](../../examples/exe_with_static_libs/doctest_force_link_static_lib_in_target.cmake). It is unintrusive - no source file gets changed - everything is done with compiler flags per source files. An example project using it can be found [**here**](../../examples/exe_with_static_libs) - the commented part of the CMakeLists.txt file.
diff --git a/doc/markdown/parameterized-tests.md b/doc/markdown/parameterized-tests.md
index 4613818..19df638 100644
--- a/doc/markdown/parameterized-tests.md
+++ b/doc/markdown/parameterized-tests.md
@@ -8,43 +8,43 @@ There will be proper support for this in the future. For now there are 2 ways of
- extracting the asserts in a helper function and calling it with a user-constructed array of data:
-```c++
-void doChecks(int data) {
- // do asserts with data
-}
-
-TEST_CASE("test name") {
- std::vector<int> data {1, 2, 3, 4, 5, 6};
-
- for(auto& i : data) {
- CAPTURE(i); // log the current input data
- doChecks(i);
+ ```c++
+ void doChecks(int data) {
+ // do asserts with data
}
-}
-```
+
+ TEST_CASE("test name") {
+ std::vector<int> data {1, 2, 3, 4, 5, 6};
+
+ for(auto& i : data) {
+ CAPTURE(i); // log the current input data
+ doChecks(i);
+ }
+ }
+ ```
This has several drawbacks:
- in case of an exception (or a ```REQUIRE``` assert failing) the entire test case ends and the checks are not done for the rest of the input data
- - the user has to manually log the data with calls to ```CAPTURE()``` (```INFO()```)
+ - the user has to manually log the data with calls to ```CAPTURE()``` ( or ```INFO()```)
- more boilerplate - doctest should supply primitives for generating data but currently doesnt - so the user has to write his own data generation
- using subcases to initialize data differently:
-```c++
-TEST_CASE("test name") {
- int data;
- SUBCASE("") { data = 1; }
- SUBCASE("") { data = 2; }
-
- CAPTURE(data);
-
- // do asserts with data
-}
-```
+ ```c++
+ TEST_CASE("test name") {
+ int data;
+ SUBCASE("") { data = 1; }
+ SUBCASE("") { data = 2; }
+
+ CAPTURE(data);
+
+ // do asserts with data
+ }
+ ```
This has the following drawbacks:
- doesn't scale well - it is very impractical to write such code for more than a few different inputs
- - the user has to manually log the data with calls to ```CAPTURE()``` (```INFO()```)
+ - the user has to manually log the data with calls to ```CAPTURE()``` (or ```INFO()```)
Stay tuned for proper value-parameterization in doctest!
diff --git a/doc/markdown/readme.md b/doc/markdown/readme.md
index 670b216..9158676 100644
--- a/doc/markdown/readme.md
+++ b/doc/markdown/readme.md
@@ -20,6 +20,7 @@ Usage:
- [Configuration](configuration.md)
- [String conversions](stringification.md)
- [FAQ](faq.md)
+- [Build systems](build-systems.md)
- [Examples](../../examples)
This library is free, and will stay free but needs your support to sustain its development. There are lots of [**new features**](roadmap.md) and maintenance to do. If you work for a company using **doctest** or have the means to do so, please consider financial support.
diff --git a/doc/markdown/roadmap.md b/doc/markdown/roadmap.md
index e8fb547..0e78996 100644
--- a/doc/markdown/roadmap.md
+++ b/doc/markdown/roadmap.md
@@ -17,18 +17,6 @@ Planned features for future releases - order changes constantly...
- https://www.paypal.me/onqtam
- https://github.com/jch/html-pipeline/blob/master/lib/html/pipeline/sanitization_filter.rb#L45-L48
- - add a new page for build systems and integration
- - copying the header directly
- - getting the header with a cmake script - perhaps using ExternalProject() or something like that
- - using cmake directly
- - using it as a package (the install target)
- - getting it from vcpkg/hunter/conan/cppan/etc.
- https://www.micheleadduci.net/blog/2016/12/11/building-modular-cpp-applications-with-cmake/
- https://github.com/Microsoft/vcpkg/blob/master/ports/doctest/portfile.cmake
- https://github.com/ruslo/hunter/blob/master/cmake/configs/default.cmake#L131
- https://github.com/ruslo/hunter/blob/master/cmake/projects/doctest/hunter.cmake
- https://github.com/ruslo/hunter/tree/master/examples/doctest
-package managers?
### For 1.3:
diff --git a/scripts/release_process.md b/scripts/release_process.md
index 0d544c2..ddd01a9 100644
--- a/scripts/release_process.md
+++ b/scripts/release_process.md
@@ -9,4 +9,10 @@
- commit in master and push
- create github release with the same semver tag as the changelog
- merge master in dev
-- update vcpkg package with a PR - https://github.com/Microsoft/vcpkg/tree/master/ports/doctest
+- update packages
+ - vcpkg https://github.com/Microsoft/vcpkg/tree/master/ports/doctest
+ - hunter
+ - https://github.com/ruslo/hunter/blob/master/cmake/configs/default.cmake
+ - https://github.com/ruslo/hunter/blob/master/cmake/projects/doctest/hunter.cmake
+ - conan
+ - cppan