C++ development notes
Cmake as project CLI, Embedding and extracting behaviour test specs
Cmake as project CLI
When working on my C++ projects, I use Cmake for building, but also for other tasks, like pretty-printing and lauching tests.
In other words, I consider Cmake as my project CLI, and don’t feel the need to write a specialized CLI to maintain for that.
However, typing cmake --build build -- <the tasks to launch> is quite tedious, and makes the CLI aspect very clunky. The same for when I need to refresh the build directory, with cmake -B build .--fresh.
I recently realized that I could define some alias for bash, and now, I type e.g. cmm prettier verify to launch the prettier task followed by the verify task. And the refresh of the build directory is cmi .
Get David Sporn’s stories in your inbox
Join Medium for free to get updates from this writer.
Now it feels like a sleek CLI to use.
Embedding and extracting behaviour test specs
I’m a sucker for written specs, especially for written specs of behavioral tests.
At the same times, I can see how painful it is to maintain a specification file against the corresponding actual code.
As a first steps, I use a convention to copy the specification of the tests as special comment, and then a bash script would extract only thous lines, and the test name.
The final goal is to have a script that would extract the test descriptions, and copy them to the main doxygen page for the code under test.
See a test runner with the embedded comments here : https://github.com/sporniket/monorepo-cpp-apps/blob/main/cmnlib-term/src-tests/vt-input/TestRunner--VtInputFromCharacters.cpp
See the extraction script : https://github.com/sporniket/monorepo-cpp-apps/blob/main/extract-doc-from-test-runner.sh





