mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-24 22:36:10 +01:00
Update build instructions in contributing.md
We now show the more modern `-S {source}` instead of the old and undocumented `-H{source}` CMake flag, and also show the available presets, instead of individually specifying the different testing options. Closes #2593
This commit is contained in:
parent
584973a485
commit
a209bcfb54
@ -55,6 +55,15 @@ tests from `SelfTest` through a specific reporter and then compare the
|
|||||||
generated output with a known good output ("Baseline"). By default, new
|
generated output with a known good output ("Baseline"). By default, new
|
||||||
tests should be placed here.
|
tests should be placed here.
|
||||||
|
|
||||||
|
To configure a Catch2 build with just the basic tests, use the `basic-tests`
|
||||||
|
preset, like so:
|
||||||
|
|
||||||
|
```
|
||||||
|
# Assuming you are in Catch2's root folder
|
||||||
|
|
||||||
|
cmake -B basic-test-build -S . -DCMAKE_BUILD_TYPE=Debug --preset basic-tests
|
||||||
|
```
|
||||||
|
|
||||||
However, not all tests can be written as plain unit tests. For example,
|
However, not all tests can be written as plain unit tests. For example,
|
||||||
checking that Catch2 orders tests randomly when asked to, and that this
|
checking that Catch2 orders tests randomly when asked to, and that this
|
||||||
random ordering is subset-invariant, is better done as an integration
|
random ordering is subset-invariant, is better done as an integration
|
||||||
@ -76,21 +85,23 @@ configuration and require separate compilation.
|
|||||||
Finally, CMake config tests test that you set Catch2's compile-time
|
Finally, CMake config tests test that you set Catch2's compile-time
|
||||||
configuration options through CMake, using CMake options of the same name.
|
configuration options through CMake, using CMake options of the same name.
|
||||||
|
|
||||||
None of these tests are enabled by default. To enable them, add
|
These test categories can be enabled one by one, by passing
|
||||||
`-DCATCH_BUILD_EXAMPLES=ON`, `-DCATCH_BUILD_EXTRA_TESTS=ON`, and
|
`-DCATCH_BUILD_EXAMPLES=ON`, `-DCATCH_BUILD_EXTRA_TESTS=ON`, and
|
||||||
`-DCATCH_ENABLE_CONFIGURE_TESTS=ON` when configuration the CMake build.
|
`-DCATCH_ENABLE_CONFIGURE_TESTS=ON` when configuring the build.
|
||||||
|
|
||||||
Bringing this all together, the steps below should configure, build,
|
Catch2 also provides a preset that promises to enable _all_ test types,
|
||||||
and run all tests in the `Debug` compilation.
|
`all-tests`.
|
||||||
|
|
||||||
|
The snippet below will build & run all tests, in `Debug` compilation mode.
|
||||||
|
|
||||||
<!-- snippet: catch2-build-and-test -->
|
<!-- snippet: catch2-build-and-test -->
|
||||||
<a id='snippet-catch2-build-and-test'></a>
|
<a id='snippet-catch2-build-and-test'></a>
|
||||||
```sh
|
```sh
|
||||||
# 1. Regenerate the amalgamated distribution
|
# 1. Regenerate the amalgamated distribution (some tests are built against it)
|
||||||
./tools/scripts/generateAmalgamatedFiles.py
|
./tools/scripts/generateAmalgamatedFiles.py
|
||||||
|
|
||||||
# 2. Configure the full test build
|
# 2. Configure the full test build
|
||||||
cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON
|
cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests
|
||||||
|
|
||||||
# 3. Run the actual build
|
# 3. Run the actual build
|
||||||
cmake --build debug-build
|
cmake --build debug-build
|
||||||
|
@ -6,7 +6,7 @@ rem 1. Regenerate the amalgamated distribution
|
|||||||
python tools\scripts\generateAmalgamatedFiles.py
|
python tools\scripts\generateAmalgamatedFiles.py
|
||||||
|
|
||||||
rem 2. Configure the full test build
|
rem 2. Configure the full test build
|
||||||
cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_ENABLE_CONFIGURE_TESTS=ON
|
cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests
|
||||||
|
|
||||||
rem 3. Run the actual build
|
rem 3. Run the actual build
|
||||||
cmake --build debug-build
|
cmake --build debug-build
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
./tools/scripts/generateAmalgamatedFiles.py
|
./tools/scripts/generateAmalgamatedFiles.py
|
||||||
|
|
||||||
# 2. Configure the full test build
|
# 2. Configure the full test build
|
||||||
cmake -Bdebug-build -H. -DCMAKE_BUILD_TYPE=Debug -DCATCH_DEVELOPMENT_BUILD=ON -DCATCH_BUILD_EXAMPLES=ON -DCATCH_BUILD_EXTRA_TESTS=ON -DCATCH_ENABLE_CONFIGURE_TESTS=ON
|
cmake -B debug-build -S . -DCMAKE_BUILD_TYPE=Debug --preset all-tests
|
||||||
|
|
||||||
# 3. Run the actual build
|
# 3. Run the actual build
|
||||||
cmake --build debug-build
|
cmake --build debug-build
|
||||||
|
Loading…
Reference in New Issue
Block a user