2017-06-29 21:02:11 +08:00
|
|
|
//===- TestUtilities.h ------------------------------------------*- C++ -*-===//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2017-06-29 21:02:11 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H
|
|
|
|
#define LLDB_UNITTESTS_UTILITY_HELPERS_TESTUTILITIES_H
|
|
|
|
|
2019-05-07 04:01:21 +08:00
|
|
|
#include "llvm/ADT/SmallString.h"
|
2017-06-29 21:02:11 +08:00
|
|
|
#include "llvm/ADT/Twine.h"
|
2019-05-07 04:01:21 +08:00
|
|
|
#include "llvm/Support/Error.h"
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
#include "llvm/Support/FileUtilities.h"
|
2017-06-29 21:02:11 +08:00
|
|
|
#include <string>
|
|
|
|
|
2019-05-07 04:01:21 +08:00
|
|
|
#define ASSERT_NO_ERROR(x) \
|
|
|
|
if (std::error_code ASSERT_NO_ERROR_ec = x) { \
|
|
|
|
llvm::SmallString<128> MessageStorage; \
|
|
|
|
llvm::raw_svector_ostream Message(MessageStorage); \
|
|
|
|
Message << #x ": did not return errc::success.\n" \
|
|
|
|
<< "error number: " << ASSERT_NO_ERROR_ec.value() << "\n" \
|
|
|
|
<< "error message: " << ASSERT_NO_ERROR_ec.message() << "\n"; \
|
|
|
|
GTEST_FATAL_FAILURE_(MessageStorage.c_str()); \
|
|
|
|
} else { \
|
|
|
|
}
|
|
|
|
|
2017-06-29 21:02:11 +08:00
|
|
|
namespace lldb_private {
|
|
|
|
std::string GetInputFilePath(const llvm::Twine &name);
|
unittests: Use yaml2obj as a library instead of an external process
Summary:
Recently, yaml2obj has been turned into a library. This means we can use
it from our unit tests directly, instead of shelling out to an external
process. This patch does just that.
Reviewers: JDevlieghere, aadsm, espindola, jdoerfert
Subscribers: emaste, mgorny, arichardson, MaskRay, jhenderson, abrachet, lldb-commits
Differential Revision: https://reviews.llvm.org/D65949
llvm-svn: 369374
2019-08-20 20:28:36 +08:00
|
|
|
|
|
|
|
class TestFile {
|
|
|
|
public:
|
|
|
|
static llvm::Expected<TestFile> fromYaml(llvm::StringRef Yaml);
|
|
|
|
static llvm::Expected<TestFile> fromYamlFile(const llvm::Twine &Name);
|
|
|
|
|
|
|
|
TestFile(TestFile &&RHS) : Name(std::move(RHS.Name)) {
|
|
|
|
RHS.Name = llvm::None;
|
|
|
|
}
|
|
|
|
|
|
|
|
~TestFile();
|
|
|
|
|
|
|
|
llvm::StringRef name() { return *Name; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
TestFile(llvm::StringRef Name, llvm::FileRemover &&Remover) : Name(Name) {
|
|
|
|
Remover.releaseFile();
|
|
|
|
}
|
|
|
|
void operator=(const TestFile &) = delete;
|
|
|
|
|
|
|
|
llvm::Optional<std::string> Name;
|
|
|
|
};
|
2017-06-29 21:02:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|