Skip to content

Commit

Permalink
Release 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
fredericbonnet committed Mar 6, 2020
1 parent 6a3d0f9 commit 085089c
Show file tree
Hide file tree
Showing 8 changed files with 138 additions and 39 deletions.
27 changes: 25 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,28 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [1.3.0] - 2020-03-06

### Added

- Add test suite
- Make default logger/filter/hooks public:

- `PICOTEST_FILTER_DEFAULT`
- `PICOTEST_FAILURE_LOGGER_DEFAULT`
- `PICOTEST_CASE_ENTER_DEFAULT`
- `PICOTEST_CASE_LEAVE_DEFAULT`
- `PICOTEST_ASSERT_BEFORE_DEFAULT`
- `PICOTEST_ASSERT_AFTER_DEFAULT`
- `PICOTEST_FIXTURE_BEFORE_SETUP_DEFAULT`
- `PICOTEST_FIXTURE_AFTER_SETUP_DEFAULT`
- `PICOTEST_FIXTURE_BEFORE_TEARDOWN_DEFAULT`
- `PICOTEST_FIXTURE_AFTER_TEARDOWN_DEFAULT`
- `PICOTEST_SUITE_ENTER_DEFAULT`
- `PICOTEST_SUITE_LEAVE_DEFAULT`
- `PICOTEST_SUITE_BEFORE_SUBTEST_DEFAULT`
- `PICOTEST_SUITE_AFTER_SUBTEST_DEFAULT`

## [1.2.1] - 2020-03-02

### Fixed
Expand All @@ -29,7 +51,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- Add PICOTEST_FAILURE
- Add `PICOTEST_FAILURE`

### Fixed

Expand All @@ -41,7 +63,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

- First release.

[unreleased]: https://github.com/fredericbonnet/picotest/compare/v1.2.1...HEAD
[unreleased]: https://github.com/fredericbonnet/picotest/compare/v1.3.0...HEAD
[1.3.0]: https://github.com/fredericbonnet/picotest/compare/v1.2.1...v1.3.0
[1.2.1]: https://github.com/fredericbonnet/picotest/compare/v1.2.0...v1.2.1
[1.2.0]: https://github.com/fredericbonnet/picotest/compare/v1.1.0...v1.2.0
[1.1.0]: https://github.com/fredericbonnet/picotest/compare/v1.0.0...v1.1.0
Expand Down
52 changes: 39 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@ the xUnit principles:

https://en.wikipedia.org/wiki/XUnit


## License

PicoTest is released under the terms of the The 3-Clause BSD License:

https://opensource.org/licenses/BSD-3-Clause


## Installation

PicoTest is a single-file package, everything is defined in the header file
`picotest.h`. So you can either install this file in a standard location, or
copy it within your project source tree.


## Usage

Simply include the file in your source file, then start writing your tests!
Expand All @@ -42,7 +39,6 @@ http://www.stack.nl/~dimitri/doxygen/
You can rebuild the documentation from scratch using the provided `Doxyfile`
file.


## Examples

The `examples` subdirectory contains several example source files that
Expand All @@ -54,10 +50,38 @@ toolchain:

https://cmake.org/

## Tests

PicoTest is self-tested and comes with a complete test suite that covers all
aspects of the framework. This guarantees that PicoTest is production-ready.

The test suite itself is a good real-world example of PicoTest in action.

Building and running the test suite requires CMake (see next section for more
information). To build the suite:

```sh
cd tests
cmake -S . -B build
cmake --build build
```

The build process makes use of the test discovery mechanism described in the
next section.

To run the suite using CTest:

```sh
cd tests/build
ctest
```

You can also run the suite executable `test_picotest` directly from the CMake
output directory.

## Integration with CMake

PicoTest provides a CMake module definition for easier integration with
PicoTest provides a CMake module definition for easier integration with
other CMake projects. In particular, it comes with an auto-discovery script for
CTest that makes use of the test traversal features of PicoTest.

Expand All @@ -66,7 +90,7 @@ The file `FindPicoTest.cmake` is the module definition. Add this file to your

```cmake
find_package(PicoTest)
```
```

You can then add the `PicoTest` dependency to your targets, e.g.:

Expand All @@ -75,9 +99,10 @@ add_executable(my_test_runner)
target_link_libraries(my_test_runner
PRIVATE PicoTest
)
```
```

If you also use CTest for test automation with `enable_testing()`, you can also call the provided `picotest_discover_tests` macro to integrate PicoTest test
If you also use CTest for test automation with `enable_testing()`, you can also
call the provided `picotest_discover_tests` macro to integrate PicoTest test
cases in your build process automatically. For example, assuming that the
`my_test_runner` executable:

Expand All @@ -86,7 +111,8 @@ cases in your build process automatically. For example, assuming that the
- when passed `<test_name>`, will execute the matching test case.

Then the following lines will:
1. execute `my_test_runner -l` as a post-build command to `my_test_runner`,

1. execute `my_test_runner -l` as a post-build command to `my_test_runner`,
2. add each discovered test case using `add_test(<test_name>)`,
3. when invoking the `test` rule, execute each test unitarily with
`my_test_runner <test_name>`.
Expand All @@ -96,20 +122,20 @@ enable_testing()
picotest_discover_tests(my_test_runner
TEST_LIST_OPTION "-l"
)
```

```

## Development

PicoTest was developed on Windows 10 and Linux Ubuntu 16.04 using the following
tools:

- IDE: Visual Studio Code
- Build tool: CMake 3.11.0
- Build tool: CMake 3.15.2
- Windows toolchain: Microsoft Visual C++ Build Tools 14
- Linux toolchain: GCC 5.4.0

It should work with any reasonably modern C compiler that supports variadic macros.
It should work with any reasonably modern C compiler that supports variadic
macros.

The assertion mechanism relies on `setjmp()` / `longjmp()`. While these
functions are discouraged for production code, their usage is acceptable in the
Expand Down
12 changes: 10 additions & 2 deletions docs/html/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,13 @@ <h2>Examples</h2>
<p>The <code>examples</code> subdirectory contains several example source files that demonstrate the various features of PicoTest. These examples are also integrated in the documentation.</p>
<p>Building the examples requires the CMake build tool along with your favorite toolchain:</p>
<p><a href="https://cmake.org/">https://cmake.org/</a></p>
<h2>Tests</h2>
<p>PicoTest is self-tested and comes with a complete test suite that covers all aspects of the framework. This guarantees that PicoTest is production-ready.</p>
<p>The test suite itself is a good real-world example of PicoTest in action.</p>
<p>Building and running the test suite requires CMake (see next section for more information). To build the suite:</p>
<div class="fragment"><div class="line">cd tests</div><div class="line">cmake -S . -B build</div><div class="line">cmake --build build</div></div><!-- fragment --><p>The build process makes use of the test discovery mechanism described in the next section.</p>
<p>To run the suite using CTest:</p>
<div class="fragment"><div class="line">cd tests/build</div><div class="line">ctest</div></div><!-- fragment --><p>You can also run the suite executable <code>test_picotest</code> directly from the CMake output directory.</p>
<h2>Integration with CMake</h2>
<p>PicoTest provides a CMake module definition for easier integration with other CMake projects. In particular, it comes with an auto-discovery script for CTest that makes use of the test traversal features of PicoTest.</p>
<p>The file <code>FindPicoTest.cmake</code> is the module definition. Add this file to your <code>CMAKE_MODULE_PATH</code>, and add the following line to your CMake project:</p>
Expand All @@ -94,7 +101,8 @@ <h2>Integration with CMake</h2>
<li>when passed the <code>-l</code> option, will list all its test cases using the <code>PICOTEST_TRAVERSE</code> feature.</li>
<li>when passed <code>&lt;test_name&gt;</code>, will execute the matching test case.</li>
</ul>
<p>Then the following lines will:</p><ol type="1">
<p>Then the following lines will:</p>
<ol type="1">
<li>execute <code>my_test_runner -l</code> as a post-build command to <code>my_test_runner</code>,</li>
<li>add each discovered test case using <code>add_test(&lt;test_name&gt;)</code>,</li>
<li>when invoking the <code>test</code> rule, execute each test unitarily with <code>my_test_runner &lt;test_name&gt;</code>.</li>
Expand All @@ -103,7 +111,7 @@ <h2>Integration with CMake</h2>
<p>PicoTest was developed on Windows 10 and Linux Ubuntu 16.04 using the following tools:</p>
<ul>
<li>IDE: Visual Studio Code</li>
<li>Build tool: CMake 3.11.0</li>
<li>Build tool: CMake 3.15.2</li>
<li>Windows toolchain: Microsoft Visual C++ Build Tools 14</li>
<li>Linux toolchain: GCC 5.4.0</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion docs/html/picotest_8h_source.html

Large diffs are not rendered by default.

52 changes: 39 additions & 13 deletions docs/xml/_r_e_a_d_m_e_8md.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@
<codeline></codeline>
<codeline><highlight class="normal">https://en.wikipedia.org/wiki/XUnit</highlight></codeline>
<codeline></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>License</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">PicoTest<sp/>is<sp/>released<sp/>under<sp/>the<sp/>terms<sp/>of<sp/>the<sp/>The<sp/>3-Clause<sp/>BSD<sp/>License:</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">https://opensource.org/licenses/BSD-3-Clause</highlight></codeline>
<codeline></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Installation</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">PicoTest<sp/>is<sp/>a<sp/>single-file<sp/>package,<sp/>everything<sp/>is<sp/>defined<sp/>in<sp/>the<sp/>header<sp/>file</highlight></codeline>
<codeline><highlight class="normal">`picotest.h`.<sp/>So<sp/>you<sp/>can<sp/>either<sp/>install<sp/>this<sp/>file<sp/>in<sp/>a<sp/>standard<sp/>location,<sp/>or</highlight></codeline>
<codeline><highlight class="normal">copy<sp/>it<sp/>within<sp/>your<sp/>project<sp/>source<sp/>tree.</highlight></codeline>
<codeline></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Usage</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">Simply<sp/>include<sp/>the<sp/>file<sp/>in<sp/>your<sp/>source<sp/>file,<sp/>then<sp/>start<sp/>writing<sp/>your<sp/>tests!</highlight></codeline>
Expand All @@ -51,7 +48,6 @@
<codeline><highlight class="normal">You<sp/>can<sp/>rebuild<sp/>the<sp/>documentation<sp/>from<sp/>scratch<sp/>using<sp/>the<sp/>provided<sp/>`Doxyfile`</highlight></codeline>
<codeline><highlight class="normal">file.</highlight></codeline>
<codeline></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Examples</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">The<sp/>`examples`<sp/>subdirectory<sp/>contains<sp/>several<sp/>example<sp/>source<sp/>files<sp/>that</highlight></codeline>
Expand All @@ -63,10 +59,38 @@
<codeline></codeline>
<codeline><highlight class="normal">https://cmake.org/</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Tests</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">PicoTest<sp/>is<sp/>self-tested<sp/>and<sp/>comes<sp/>with<sp/>a<sp/>complete<sp/>test<sp/>suite<sp/>that<sp/>covers<sp/>all</highlight></codeline>
<codeline><highlight class="normal">aspects<sp/>of<sp/>the<sp/>framework.<sp/>This<sp/>guarantees<sp/>that<sp/>PicoTest<sp/>is<sp/>production-ready.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">The<sp/>test<sp/>suite<sp/>itself<sp/>is<sp/>a<sp/>good<sp/>real-world<sp/>example<sp/>of<sp/>PicoTest<sp/>in<sp/>action.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">Building<sp/>and<sp/>running<sp/>the<sp/>test<sp/>suite<sp/>requires<sp/>CMake<sp/>(see<sp/>next<sp/>section<sp/>for<sp/>more</highlight></codeline>
<codeline><highlight class="normal">information).<sp/>To<sp/>build<sp/>the<sp/>suite:</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">```sh</highlight></codeline>
<codeline><highlight class="normal">cd<sp/>tests</highlight></codeline>
<codeline><highlight class="normal">cmake<sp/>-S<sp/>.<sp/>-B<sp/>build</highlight></codeline>
<codeline><highlight class="normal">cmake<sp/>--build<sp/>build</highlight></codeline>
<codeline><highlight class="normal">```</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">The<sp/>build<sp/>process<sp/>makes<sp/>use<sp/>of<sp/>the<sp/>test<sp/>discovery<sp/>mechanism<sp/>described<sp/>in<sp/>the</highlight></codeline>
<codeline><highlight class="normal">next<sp/>section.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">To<sp/>run<sp/>the<sp/>suite<sp/>using<sp/>CTest:</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">```sh</highlight></codeline>
<codeline><highlight class="normal">cd<sp/>tests/build</highlight></codeline>
<codeline><highlight class="normal">ctest</highlight></codeline>
<codeline><highlight class="normal">```</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">You<sp/>can<sp/>also<sp/>run<sp/>the<sp/>suite<sp/>executable<sp/>`test_picotest`<sp/>directly<sp/>from<sp/>the<sp/>CMake</highlight></codeline>
<codeline><highlight class="normal">output<sp/>directory.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Integration<sp/>with<sp/>CMake</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">PicoTest<sp/>provides<sp/><sp/>a<sp/>CMake<sp/>module<sp/>definition<sp/>for<sp/>easier<sp/>integration<sp/>with</highlight></codeline>
<codeline><highlight class="normal">PicoTest<sp/>provides<sp/>a<sp/>CMake<sp/>module<sp/>definition<sp/>for<sp/>easier<sp/>integration<sp/>with</highlight></codeline>
<codeline><highlight class="normal">other<sp/>CMake<sp/>projects.<sp/>In<sp/>particular,<sp/>it<sp/>comes<sp/>with<sp/>an<sp/>auto-discovery<sp/>script<sp/>for</highlight></codeline>
<codeline><highlight class="normal">CTest<sp/>that<sp/>makes<sp/>use<sp/>of<sp/>the<sp/>test<sp/>traversal<sp/>features<sp/>of<sp/>PicoTest.</highlight></codeline>
<codeline></codeline>
Expand All @@ -75,7 +99,7 @@
<codeline></codeline>
<codeline><highlight class="normal">```cmake</highlight></codeline>
<codeline><highlight class="normal">find_package(PicoTest)</highlight></codeline>
<codeline><highlight class="normal">```<sp/></highlight></codeline>
<codeline><highlight class="normal">```</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">You<sp/>can<sp/>then<sp/>add<sp/>the<sp/>`PicoTest`<sp/>dependency<sp/>to<sp/>your<sp/>targets,<sp/>e.g.:</highlight></codeline>
<codeline></codeline>
Expand All @@ -84,9 +108,10 @@
<codeline><highlight class="normal">target_link_libraries(my_test_runner</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>PRIVATE<sp/>PicoTest</highlight></codeline>
<codeline><highlight class="normal">)</highlight></codeline>
<codeline><highlight class="normal">```<sp/></highlight></codeline>
<codeline><highlight class="normal">```</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">If<sp/>you<sp/>also<sp/>use<sp/>CTest<sp/>for<sp/>test<sp/>automation<sp/>with<sp/>`enable_testing()`,<sp/>you<sp/>can<sp/>also<sp/>call<sp/>the<sp/>provided<sp/>`picotest_discover_tests`<sp/>macro<sp/>to<sp/>integrate<sp/>PicoTest<sp/>test</highlight></codeline>
<codeline><highlight class="normal">If<sp/>you<sp/>also<sp/>use<sp/>CTest<sp/>for<sp/>test<sp/>automation<sp/>with<sp/>`enable_testing()`,<sp/>you<sp/>can<sp/>also</highlight></codeline>
<codeline><highlight class="normal">call<sp/>the<sp/>provided<sp/>`picotest_discover_tests`<sp/>macro<sp/>to<sp/>integrate<sp/>PicoTest<sp/>test</highlight></codeline>
<codeline><highlight class="normal">cases<sp/>in<sp/>your<sp/>build<sp/>process<sp/>automatically.<sp/>For<sp/>example,<sp/>assuming<sp/>that<sp/>the</highlight></codeline>
<codeline><highlight class="normal">`my_test_runner`<sp/>executable:</highlight></codeline>
<codeline></codeline>
Expand All @@ -95,7 +120,8 @@
<codeline><highlight class="normal">-<sp/>when<sp/>passed<sp/>`&lt;test_name&gt;`,<sp/>will<sp/>execute<sp/>the<sp/>matching<sp/>test<sp/>case.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">Then<sp/>the<sp/>following<sp/>lines<sp/>will:</highlight></codeline>
<codeline><highlight class="normal">1.<sp/>execute<sp/>`my_test_runner<sp/>-l`<sp/>as<sp/>a<sp/>post-build<sp/>command<sp/>to<sp/>`my_test_runner`,<sp/></highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">1.<sp/>execute<sp/>`my_test_runner<sp/>-l`<sp/>as<sp/>a<sp/>post-build<sp/>command<sp/>to<sp/>`my_test_runner`,</highlight></codeline>
<codeline><highlight class="normal">2.<sp/>add<sp/>each<sp/>discovered<sp/>test<sp/>case<sp/>using<sp/>`add_test(&lt;test_name&gt;)`,</highlight></codeline>
<codeline><highlight class="normal">3.<sp/>when<sp/>invoking<sp/>the<sp/>`test`<sp/>rule,<sp/>execute<sp/>each<sp/>test<sp/>unitarily<sp/>with</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/>`my_test_runner<sp/>&lt;test_name&gt;`.</highlight></codeline>
Expand All @@ -105,20 +131,20 @@
<codeline><highlight class="normal">picotest_discover_tests(my_test_runner</highlight></codeline>
<codeline><highlight class="normal"><sp/><sp/><sp/><sp/>TEST_LIST_OPTION<sp/>&quot;-l&quot;</highlight></codeline>
<codeline><highlight class="normal">)</highlight></codeline>
<codeline><highlight class="normal">```<sp/></highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">```</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">##<sp/>Development</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">PicoTest<sp/>was<sp/>developed<sp/>on<sp/>Windows<sp/>10<sp/>and<sp/>Linux<sp/>Ubuntu<sp/>16.04<sp/>using<sp/>the<sp/>following</highlight></codeline>
<codeline><highlight class="normal">tools:</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">-<sp/>IDE:<sp/>Visual<sp/>Studio<sp/>Code</highlight></codeline>
<codeline><highlight class="normal">-<sp/>Build<sp/>tool:<sp/>CMake<sp/>3.11.0<sp/></highlight></codeline>
<codeline><highlight class="normal">-<sp/>Build<sp/>tool:<sp/>CMake<sp/>3.15.2</highlight></codeline>
<codeline><highlight class="normal">-<sp/>Windows<sp/>toolchain:<sp/>Microsoft<sp/>Visual<sp/>C++<sp/>Build<sp/>Tools<sp/>14</highlight></codeline>
<codeline><highlight class="normal">-<sp/>Linux<sp/>toolchain:<sp/>GCC<sp/>5.4.0</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">It<sp/>should<sp/>work<sp/>with<sp/>any<sp/>reasonably<sp/>modern<sp/>C<sp/>compiler<sp/>that<sp/>supports<sp/>variadic<sp/>macros.</highlight></codeline>
<codeline><highlight class="normal">It<sp/>should<sp/>work<sp/>with<sp/>any<sp/>reasonably<sp/>modern<sp/>C<sp/>compiler<sp/>that<sp/>supports<sp/>variadic</highlight></codeline>
<codeline><highlight class="normal">macros.</highlight></codeline>
<codeline></codeline>
<codeline><highlight class="normal">The<sp/>assertion<sp/>mechanism<sp/>relies<sp/>on<sp/>`setjmp()`<sp/>/<sp/>`longjmp()`.<sp/>While<sp/>these</highlight></codeline>
<codeline><highlight class="normal">functions<sp/>are<sp/>discouraged<sp/>for<sp/>production<sp/>code,<sp/>their<sp/>usage<sp/>is<sp/>acceptable<sp/>in<sp/>the</highlight></codeline>
Expand Down
Loading

0 comments on commit 085089c

Please sign in to comment.