9#ifndef LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
10#define LLVM_TESTING_SUPPORT_SUPPORTHELPERS_H
17#include "gmock/gmock-matchers.h"
18#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 std::optional<T> &>()
const {
68 return ::testing::MakeMatcher(
69 new Impl<T>(::testing::SafeMatcherCast<T>(ValueMatcher)));
72 template <
class T,
class O = std::optional<T>>
73 class Impl :
public ::testing::MatcherInterface<const O &> {
75 explicit Impl(const ::testing::Matcher<T> &ValueMatcher)
76 : ValueMatcher(ValueMatcher) {}
79 testing::MatchResultListener *L)
const override {
80 return Input && ValueMatcher.MatchAndExplain(*Input, 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;
103template <
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())
Analysis containing CSE Info
This file defines the SmallString class.
Tagged union holding either a T or a Error.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
Target - Wrapper for Target specific information.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
void DescribeNegationTo(std::ostream *OS) const override
void DescribeTo(std::ostream *OS) const override
Impl(const ::testing::Matcher< T > &ValueMatcher)
bool MatchAndExplain(const O &Input, testing::MatchResultListener *L) const override
A raw_ostream that writes to a file descriptor.
raw_os_ostream - A raw_ostream that writes to an std::ostream.
A RAII object that creates a temporary directory upon initialization and removes it upon destruction.
const char * c_str()
The null-terminated C string pointing to the path.
StringRef path() const
The path to the temporary directory.
TempDir(StringRef Name, bool Unique=false)
Creates a managed temporary directory.
TempDir & operator=(TempDir &&)=default
TempDir & operator=(const TempDir &)=delete
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...
TempDir(TempDir &&)=default
TempDir(const TempDir &)=delete
A RAII object that creates a file upon initialization and removes it upon destruction.
StringRef path() const
The path to the file.
TempFile(StringRef Name, StringRef Suffix="", StringRef Contents="", bool Unique=false)
Creates a managed file.
TempFile(const TempFile &)=delete
TempFile(TempFile &&)=default
TempFile & operator=(TempFile &&)=default
TempFile & operator=(const TempFile &)=delete
A RAII object that creates a link upon initialization and removes it upon destruction.
StringRef path() const
The path to the link.
TempLink & operator=(TempLink &&)=default
TempLink & operator=(const TempLink &)=delete
TempLink(TempLink &&)=default
TempLink(const TempLink &)=delete
TempLink(StringRef Target, StringRef Link)
Creates a managed link at path Link pointing to Target.
void PrintTo(const ErrorHolder &Err, std::ostream *Out)
std::error_code remove_directories(const Twine &path, bool IgnoreErrors=true)
Recursively delete a directory.
std::error_code create_link(const Twine &to, const Twine &from)
Create a link from from to to.
std::error_code real_path(const Twine &path, SmallVectorImpl< char > &output, bool expand_tilde=false)
Collapse all .
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 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...
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.
std::error_code createUniqueDirectory(const Twine &Prefix, SmallVectorImpl< char > &ResultPath)
void append(SmallVectorImpl< char > &path, const Twine &a, const Twine &b="", const Twine &c="", const Twine &d="")
Append to path.
SmallString< 128 > getInputFileDirectory(const char *Argv0)
This is an optimization pass for GlobalISel generic memory operations.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
detail::ValueIsMatcher< InnerMatcher > ValueIs(const InnerMatcher &ValueMatcher)
Matches an std::optional<T> with a value that conforms to an inner matcher.
Implement std::hash so that hash_code can be used in STL containers.
std::vector< std::shared_ptr< ErrorInfoBase > > Infos
ExpectedHolder(ErrorHolder Err, Expected< T > &Exp)