Add our own copy of the gtest discovery scripts from CMake a few reasons:
* Use the very latest version which supports PRE_TEST for Windows
* Fix usage of [] symbols in file paths that fail with the zsh shell
* Disable asan leak checker when discovering tests
This means Windows also no longer requires the very latest CMake 3.18.
This bumps the minimum requirement for cmake from 3.10 to 3.18 on windows
if `WITH_GTESTS` is enabled.
Reviewed By: sergey brecht sybren campbellbarton
Differential Revision: https://developer.blender.org/D8405
The buildbot uses a separate `CMAKE_INSTALL_PREFIX`. This means that
the unit test could not find its USD JSON files in the build directory.
Using `${CMAKE_INSTALL_PREFIX}` instead of `$<TARGET_FILE_DIR:blender>`
solved this.
MSVC does need the wholearchive flag but it was not set,
so no tests were actually linked into the binary.
Reviewed By: sybren
Differential Revision: https://developer.blender.org/D8404
CMake, when it's configuring the project, runs the `blender_test` test
runner (if it exists from a previous build) to discover which tests it
contains. At this time none of the tests themselves are run, so it's not
that useful to run ASAN and have it break things when there are memory
leaks.
This commit disables ASAN by injecting `ASAN_OPTIONS="detect_leaks=0"` in
the environment variables.
It is not enough to use `set(ENV{ASAN_OPTIONS} "detect_leaks=0")` in
`tests/gtests/runner/CMakeLists.txt`, as it wouldn't be passed to the child
process.
This commit is a followup of {D7649}, and ports the USD tests to the new
testing approach. It moves test code from `tests/gtests/usd` into
`source/blender/io/common` and `source/blender/io/usd`, and adjusts the
use of namespaces to be consistent with the other tests.
I decided to put one test into `io/usd/tests`, instead of
`io/usd/intern`. The reason is that this test does not correspond with a
single file in that directory; instead, it tests Blender's integration
with the USD library itself.
There are two new CLI arguments for the Big Test Runner:
- `--test-assets-dir`, which points to the `lib/tests` directory in the
SVN repository. This allows unit tests to find test assets.
- `--test-release-dir`, which points to `bin/{BLENDER_VERSION}` in the
build directory. At the moment this is only used by the USD test.
The CLI arguments are automatically passed to the Big Test Runner when
using `ctest`. When manually running the tests, the arguments are only
required when there is a test run that needs them.
For more info about splitting some code into 'common', see
rB084c5d6c7e2cf8.
No functional changes to the tests themselves, only to the way they are
built & run.
Differential Revision: https://developer.blender.org/D8314
Reviewed by: brecht, mont29
This commit introduces a new way to build unit tests. It is now possible
for each module to generate its own test library. The tests in these
libraries are then bundled into a single executable.
The test executable can be run with `ctest`. Even though the tests
reside in a single executable, they are still exposed as individual
tests to `ctest`, and thus can be selected via its `-R` argument.
Not yet ported tests still build & run as before.
The following rules apply:
- Test code should reside in the same directory as the code under test.
- Tests that target functionality in `somefile.{c,cc}` should reside in
`somefile_test.cc`.
- The namespace for tests is the `tests` sub-namespace of the code under
test. For example, tests for `blender::bke` should be in
`blender::bke:tests`.
- The test files should be listed in the module's `CMakeLists.txt` in a
`blender_add_test_lib()` call. See the `blenkernel` module for an
example.
Reviewed By: brecht
Differential Revision: https://developer.blender.org/D7649