aboutsummaryrefslogtreecommitdiff
path: root/docs/tool-maintainers/testing.md
diff options
context:
space:
mode:
authorAlexander Neumann <alexander.neumann@hamburg.de>2019-09-20 12:24:23 +0200
committerAlexander Neumann <alexander.neumann@hamburg.de>2019-09-20 12:24:23 +0200
commit5b1e426929b40a9b60809284993b424b841a28fc (patch)
treebd12300ad859bababb7d4acc03700fd31949fddc /docs/tool-maintainers/testing.md
parent279e25aecfe30f55296881ea9b0236c1d6ee030a (diff)
parent358ec0954d9b71b0def4fd4b4dbafdd0b8478d81 (diff)
downloadvcpkg-5b1e426929b40a9b60809284993b424b841a28fc.tar.gz
vcpkg-5b1e426929b40a9b60809284993b424b841a28fc.zip
Merge remote-tracking branch 'upstream/master' into path_separator
# Conflicts: # scripts/cmake/vcpkg_common_definitions.cmake
Diffstat (limited to 'docs/tool-maintainers/testing.md')
-rw-r--r--docs/tool-maintainers/testing.md36
1 files changed, 13 insertions, 23 deletions
diff --git a/docs/tool-maintainers/testing.md b/docs/tool-maintainers/testing.md
index 28cc9e099..0284a2650 100644
--- a/docs/tool-maintainers/testing.md
+++ b/docs/tool-maintainers/testing.md
@@ -1,13 +1,11 @@
-Testing
-=======
+# Testing
Testing vcpkg is important whenever one makes changes to the tool itself, and
writing new tests and keeping them up to date is also very important. If one's
code is subtly broken, we'd rather find it out right away than a few weeks down
the line when someone complains!
-Running Tests
--------------
+## Running Tests
Before anything else, we should know whether you can actually run the tests!
All you should need is a way to build vcpkg -- anything will do! All you have to
@@ -27,8 +25,7 @@ $ # i.e., ./vcpkg-test [arguments]
If you make any modifications to `vcpkg`, you'll have to do the
`cmake --build .` step again.
-Writing Tests
--------------
+## Writing Tests
In your journey to write new tests, and to modify existing tests, reading the
[Catch2 documentation] will be very helpful! Come back after reading those 😀
@@ -42,8 +39,8 @@ The layout of these tests is as follows:
// ... includes
TEST_CASE("Name of test", "[filename without the .cpp]") {
- // setup and the like
- REQUIRE(some boolean expression);
+ // setup and the like
+ REQUIRE(some boolean expression);
}
// etc.
@@ -67,12 +64,10 @@ Remember to check out the [Catch2 documentation]
if you'd like to get more advanced with your tests,
and good luck on your testing journey!
-Adding New Test Files
----------------------
+## Adding New Test Files
Adding new test files should be easy and straightforward. All it requires is
-creating a new source file in `toolsrc/src/vcpkg-test`, and then rerunning
-`CMake` in order to pick up the glob changes.
+creating a new source file in `toolsrc/src/vcpkg-test`.
### Example
@@ -85,14 +80,9 @@ First, we should create a file, `example.cpp`, in `toolsrc/src/vcpkg-test`:
#include <vcpkg-test/catch.h>
```
-This is the minimum file needed for tests; let's rebuild our CMake directory.
-You'll have to clean out the existing `out` directory for CMake to rerun
-globbing.
+This is the minimum file needed for tests; let's rebuild!
```sh
-$ cmake .. -DCMAKE_BUILD_TYPE=Debug -G Ninja
-# ...
--- Build files have been written to: $VCPKG_DIRECTORY/toolsrc/out
$ cmake --build .
[80/80] Linking CXX executable vcpkg.exe
```
@@ -101,7 +91,7 @@ Okay, now let's make sure this worked; add a test case to `example.cpp`:
```cpp
TEST_CASE("Example 1 - fail", "[example]") {
- REQUIRE(false);
+ REQUIRE(false);
}
```
@@ -123,7 +113,7 @@ $VCPKG_DIRECTORY/toolsrc/src/vcpkg-test/example.cpp(3)
...............................................................................
$VCPKG_DIRECTORY/toolsrc/src/vcpkg-test/example.cpp(14): FAILED:
- REQUIRE( false )
+ REQUIRE( false )
===============================================================================
test cases: 102 | 101 passed | 1 failed
@@ -138,9 +128,9 @@ Now let's try a more complex test, after deleting the old one;
namespace Strings = vcpkg::Strings;
TEST_CASE("Example 2 - success", "[example]") {
- std::string hello = "Hello";
- REQUIRE(Strings::case_insensitive_ascii_equals(hello, "hELLo"));
- REQUIRE_FALSE(Strings::case_insensitive_ascii_starts_with(hello, "E"));
+ std::string hello = "Hello";
+ REQUIRE(Strings::case_insensitive_ascii_equals(hello, "hELLo"));
+ REQUIRE_FALSE(Strings::case_insensitive_ascii_starts_with(hello, "E"));
}
```