Writing Tests with bpt¶
bpt will recognize certain compilable source files as
belonging to tests (or applications), depending on the
file stem (the part of the filename not including the outer-most
file extension). If a compilable source file stem ends with .test (or
.main), that source file is assumed to correspond to an executable to
generate. The filename’s second-inner stem before the .test (or .main)
will be used as the name of the generated executable.
A “test source file” is a source file whose file stem ends with .test.
When building a project, bpt will generate an executable program for each
such source file, compiling and linking it with the enclosing library and the
library’s test dependencies. The name of the test will be
generated from the next-inner stem of the filename:
Given
bar.test.cppThe stem is
bar.test, whose extension is.test, so we will generate a test.The stem of
bar.testisbar, so will generate an executable namedbar.
Given
cats.musical.test.cppThe stem is
cats.musical.test, which has extension.test, so this is a text executable.The stem of
cats.musical.testiscats.musical, so we will generate an executable namedcats.musical.Note that the dot in
cats.musicalis not significant, asbptdoes strip any further extensions.
Note
bpt will automatically append the appropriate file extension to the
generated executables based on the host and toolchain.
The compiling and linking of a project’s tests can be disabled with the
--no-tests option. This will also omit the
project’s test dependencies from the dependency solution.
The test source files of dependencies will be ignored.
Output Path¶
When a test is linked, its output directory will be a generated using a
relative filepath resolved within the test/ subdirectory of the output
directory of the build. The path to the parent directory of
the test source file relative to the source root that contains it is used as
the subdirectory within the test/ directory where the test’s executable will
be written.
Test Source Filepath |
Test Executable Output Path |
|
|
|
|
|
|
Note
The default build output directory is the _build/ directory within which
bpt was invoked. This can be controlled using the
--out option.