llvm-project/lldb/unittests/TestingSupport
Raphael Isemann 5dca0596a9 [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests
Summary:
Many of our tests need to initialize certain subsystems/plugins of LLDB such as
`FileSystem` or `HostInfo` by calling their static `Initialize` functions before the
test starts and then calling `::Terminate` after the test is done (in reverse order).
This adds a lot of error-prone boilerplate code to our testing code.

This patch adds a RAII called SubsystemRAII that ensures that we always call
::Initialize and then call ::Terminate after the test is done (and that the Terminate
calls are always in the reverse order of the ::Initialize calls). It also gets rid of
all of the boilerplate that we had for these calls.

Per-fixture initialization is still not very nice with this approach as it would
require some kind of static unique_ptr that gets manually assigned/reseted
from the gtest SetUpTestCase/TearDownTestCase functions. Because of that
I changed all per-fixture setup to now do per-test setup which can be done
by just having the SubsystemRAII as a member of the test fixture. This change doesn't
influence our normal test runtime as LIT anyway runs each test case separately
(and the Initialize/Terminate calls are anyway not very expensive). It will however
make running all tests in a single executable slightly slower.

Reviewers: labath, JDevlieghere, martong, espindola, shafik

Reviewed By: labath

Subscribers: mgorny, rnkovacs, emaste, MaskRay, abidh, lldb-commits

Tags: #lldb

Differential Revision: https://reviews.llvm.org/D71630
2019-12-23 10:38:25 +01:00
..
Host
Symbol [lldb][NFC] Return a reference from ClangASTContext::getASTContext and remove dead nullptr checks 2019-12-21 22:51:35 +01:00
CMakeLists.txt Properly EXCLUDE_FROM_ALL the testing support library 2019-08-21 08:21:51 +00:00
MockTildeExpressionResolver.cpp
MockTildeExpressionResolver.h
SubsystemRAII.h [lldb] Add a SubsystemRAII that takes care of calling Initialize and Terminate in the unit tests 2019-12-23 10:38:25 +01:00
TestUtilities.cpp [lldb] - Update unit tests after lib/ObjectYAML change. 2019-09-13 16:00:28 +00:00
TestUtilities.h unittests: Use yaml2obj as a library instead of an external process 2019-08-20 12:28:36 +00:00
module.modulemap [lldb][NFC] Move utility functions from ClangASTImporter and ClangExpressionDeclMap to own header 2019-12-20 16:13:24 +01:00