Go to the documentation of this file.
9 #ifndef LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
10 #define LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
18 #include "gmock/gmock-matchers.h"
19 #include "gtest/gtest-printers.h"
26 std::vector<std::shared_ptr<ErrorInfoBase>>
Infos;
40 OS << (Err.Success() ?
"succeeded" :
"failed");
42 const char *Delim =
" (";
43 for (
const auto &
Info : Err.Infos) {
55 *Out <<
"succeeded with value " << ::testing::PrintToString(*Item.
Exp);
64 : ValueMatcher(ValueMatcher) {}
67 operator ::testing::Matcher<const llvm::Optional<T> &>()
const {
68 return ::testing::MakeMatcher(
69 new Impl<T>(::testing::SafeMatcherCast<T>(ValueMatcher)));
73 class Impl :
public ::testing::MatcherInterface<const llvm::Optional<T> &> {
75 explicit Impl(const ::testing::Matcher<T> &ValueMatcher)
76 : ValueMatcher(ValueMatcher) {}
79 testing::MatchResultListener *L)
const override {
80 return Input && ValueMatcher.MatchAndExplain(Input.getValue(), L);
84 *OS <<
"has a value that ";
85 ValueMatcher.DescribeTo(OS);
88 *OS <<
"does not have a value that ";
89 ValueMatcher.DescribeTo(OS);
93 testing::Matcher<T> ValueMatcher;
97 InnerMatcher ValueMatcher;
103 template <
class InnerMatcher>
128 std::string UnresolvedPath(Path.str());
137 EXPECT_FALSE(EC) << EC.message();
156 const char *
c_str() {
return Path.c_str(); }
214 bool Unique =
false) {
221 if (!Suffix.empty()) {
231 EXPECT_FALSE(OS.
error());
232 if (EC || OS.
error())
std::error_code openFileForWrite(const Twine &Name, int &ResultFD, CreationDisposition Disp=CD_CreateAlways, OpenFlags Flags=OF_None, unsigned Mode=0666)
Opens the file with the given name in a write-only or read-write mode, returning its open file descri...
A RAII object that creates a file upon initialization and removes it upon destruction.
StringRef path() const
The path to the temporary directory.
This is an optimization pass for GlobalISel generic memory operations.
detail::ValueIsMatcher< InnerMatcher > ValueIs(const InnerMatcher &ValueMatcher)
Matches an llvm::Optional<T> with a value that conforms to an inner matcher.
StringRef path() const
The path to the file.
raw_os_ostream - A raw_ostream that writes to an std::ostream.
Target - Wrapper for Target specific information.
TempFile & operator=(const TempFile &)=delete
void native(const Twine &path, SmallVectorImpl< char > &result, Style style=Style::native)
Convert path to the native form.
Tagged union holding either a T or a Error.
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
SmallString< 128 > path(StringRef component) const
Creates a new path by appending the argument to the path of the managed directory using the native pa...
std::error_code create_link(const Twine &to, const Twine &from)
Create a link from from to to.
std::error_code createUniqueDirectory(const Twine &Prefix, SmallVectorImpl< char > &ResultPath)
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
TempLink & operator=(const TempLink &)=delete
Analysis containing CSE Info
ValueIsMatcher(InnerMatcher ValueMatcher)
ExpectedHolder(ErrorHolder Err, Expected< T > &Exp)
std::error_code remove_directories(const Twine &path, bool IgnoreErrors=true)
Recursively delete a directory.
TempDir & operator=(const TempDir &)=delete
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
A RAII object that creates a temporary directory upon initialization and removes it upon destruction.
SmallString< 128 > getInputFileDirectory(const char *Argv0)
std::error_code create_directory(const Twine &path, bool IgnoreExisting=true, perms Perms=owner_all|group_all)
Create the directory in path.
std::error_code remove(const Twine &path, bool IgnoreNonExisting=true)
Remove path.
std::error_code error() const
std::error_code createTemporaryFile(const Twine &Prefix, StringRef Suffix, int &ResultFD, SmallVectorImpl< char > &ResultPath, OpenFlags Flags=OF_None)
Create a file in the system temporary directory.
StringRef - Represent a constant reference to a string, i.e.
A raw_ostream that writes to a file descriptor.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void DescribeTo(std::ostream *OS) const override
const char * c_str()
The null-terminated C string pointing to the path.
void DescribeNegationTo(std::ostream *OS) const override
A RAII object that creates a link upon initialization and removes it upon destruction.
std::vector< std::shared_ptr< ErrorInfoBase > > Infos
TempDir(StringRef Name, bool Unique=false)
Creates a managed temporary directory.
void PrintTo(const ErrorHolder &Err, std::ostream *Out)
TempLink(StringRef Target, StringRef Link)
Creates a managed link at path Link pointing to Target.
bool MatchAndExplain(const llvm::Optional< T > &Input, testing::MatchResultListener *L) const override
StringRef path() const
The path to the link.
Impl(const ::testing::Matcher< T > &ValueMatcher)
TempFile(StringRef Name, StringRef Suffix="", StringRef Contents="", bool Unique=false)
Creates a managed file.