diff --git a/lldb/unittests/Target/FindFileTest.cpp b/lldb/unittests/Target/FindFileTest.cpp --- a/lldb/unittests/Target/FindFileTest.cpp +++ b/lldb/unittests/Target/FindFileTest.cpp @@ -6,6 +6,7 @@ // //===----------------------------------------------------------------------===// +#include "TestingSupport/SubsystemRAII.h" #include "TestingSupport/TestUtilities.h" #include "lldb/Host/FileSystem.h" #include "lldb/Host/HostInfo.h" @@ -24,22 +25,13 @@ namespace { struct Matches { FileSpec original; - llvm::StringRef remapped; - Matches(const char *o, const char *r) : original(o), remapped(r) {} - Matches(const char *o, llvm::sys::path::Style style, const char *r) + std::string remapped; + Matches(llvm::StringRef o, llvm::sys::path::Style style, llvm::StringRef r) : original(o, style), remapped(r) {} }; class FindFileTest : public testing::Test { -public: - void SetUp() override { - FileSystem::Initialize(); - HostInfo::Initialize(); - } - void TearDown() override { - HostInfo::Terminate(); - FileSystem::Terminate(); - } + SubsystemRAII subsystems; }; } // namespace @@ -53,11 +45,11 @@ for (const auto &match : matches) { SCOPED_TRACE(match.original.GetPath() + " -> " + match.remapped); - llvm::Optional remapped; + llvm::Optional remapped = map.FindFile(match.original); - EXPECT_TRUE(bool(remapped = map.FindFile(match.original))); - EXPECT_TRUE(FileSpec(remapped.getValue()).GetPath() == - ConstString(match.remapped).GetStringRef()); + EXPECT_TRUE(remapped); + EXPECT_EQ(FileSpec(remapped.getValue()).GetPath(), + ConstString(match.remapped).GetStringRef()); } }