Description
Since @milancurcic brought it up in #177 (comment), it might be worth to have a way to define unit tests within a test target, i.e. “export” tests from our testing framework as test targets to fpm test
. I am also thinking of tests that will require external resources, we cannot really define in a unit test.
An example is the consistency test of the version number specified in the fpm.toml
, meson.build
or CMakeLists.txt
and the internal one in a *_version
module. In this case we would either like to get the correct fpm.toml
as argument and parse it or have the build system pass the version string as command line argument. The unit test without arguments will usually be useless. The alternative would be to generate the *_version
module with configure_file
from a template, but this is nothing we can do with fpm (yet).
Other examples might be test targets requiring correctly set environment variables or test binaries that can run different tests depending on a test input file. The binary might even be an external program that takes an executable as input and provides it with input by some convention (i.e. STDIN) and expects a correct response (i.e. STDOUT or error code).
I am facing four different test scenarios with toml-f
, for which I am relying on the unit test framework of meson and it does a pretty decent job to orchestrate those different scenarios. Only one of them would be supported by fpm right now. Here are the test definitions for reference: https://github.com/toml-f/toml-f/blob/master/test/meson.build.