forked from OSchip/llvm-project
Trying to fix clang-move tests on windows build bot broken by r332717
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/10702 llvm-svn: 332732
This commit is contained in:
parent
8992d27caa
commit
db53a52ff2
|
@ -24,10 +24,6 @@ namespace clang {
|
||||||
namespace move {
|
namespace move {
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
const char TestHeaderName[] = "foo.h";
|
|
||||||
|
|
||||||
const char TestCCName[] = "foo.cc";
|
|
||||||
|
|
||||||
const char TestHeader[] = "namespace a {\n"
|
const char TestHeader[] = "namespace a {\n"
|
||||||
"class C1; // test\n"
|
"class C1; // test\n"
|
||||||
"template <typename T> class C2;\n"
|
"template <typename T> class C2;\n"
|
||||||
|
@ -196,6 +192,15 @@ const char ExpectedNewCC[] = "namespace a {\n"
|
||||||
"} // namespace b\n"
|
"} // namespace b\n"
|
||||||
"} // namespace a\n";
|
"} // namespace a\n";
|
||||||
|
|
||||||
|
#ifdef _WIN32
|
||||||
|
const char WorkingDir[] = "C:\\test";
|
||||||
|
#else
|
||||||
|
const char WorkingDir[] = "/test";
|
||||||
|
#endif
|
||||||
|
|
||||||
|
const char TestHeaderName[] = "foo.h";
|
||||||
|
const char TestCCName[] = "foo.cc";
|
||||||
|
|
||||||
std::map<std::string, std::string>
|
std::map<std::string, std::string>
|
||||||
runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
|
runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
|
||||||
const char *const Header = TestHeader,
|
const char *const Header = TestHeader,
|
||||||
|
@ -203,9 +208,9 @@ runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
|
||||||
DeclarationReporter *const Reporter = nullptr) {
|
DeclarationReporter *const Reporter = nullptr) {
|
||||||
clang::RewriterTestContext Context;
|
clang::RewriterTestContext Context;
|
||||||
|
|
||||||
|
Context.InMemoryFileSystem->setCurrentWorkingDirectory(WorkingDir);
|
||||||
|
|
||||||
std::map<llvm::StringRef, clang::FileID> FileToFileID;
|
std::map<llvm::StringRef, clang::FileID> FileToFileID;
|
||||||
std::vector<std::pair<std::string, std::string>> FileToSourceText = {
|
|
||||||
{TestHeaderName, Header}, {TestCCName, CC}};
|
|
||||||
|
|
||||||
auto CreateFiles = [&Context, &FileToFileID](llvm::StringRef Name,
|
auto CreateFiles = [&Context, &FileToFileID](llvm::StringRef Name,
|
||||||
llvm::StringRef Code) {
|
llvm::StringRef Code) {
|
||||||
|
@ -215,25 +220,21 @@ runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
|
||||||
};
|
};
|
||||||
CreateFiles(Spec.NewCC, "");
|
CreateFiles(Spec.NewCC, "");
|
||||||
CreateFiles(Spec.NewHeader, "");
|
CreateFiles(Spec.NewHeader, "");
|
||||||
CreateFiles(Spec.OldHeader, Header);
|
CreateFiles(TestHeaderName, Header);
|
||||||
CreateFiles(Spec.OldCC, CC);
|
CreateFiles(TestCCName, CC);
|
||||||
|
|
||||||
std::map<std::string, tooling::Replacements> FileToReplacements;
|
std::map<std::string, tooling::Replacements> FileToReplacements;
|
||||||
llvm::SmallString<128> InitialDirectory;
|
ClangMoveContext MoveContext = {Spec, FileToReplacements, WorkingDir, "LLVM",
|
||||||
std::error_code EC = llvm::sys::fs::current_path(InitialDirectory);
|
|
||||||
assert(!EC);
|
|
||||||
(void)EC;
|
|
||||||
ClangMoveContext MoveContext = {Spec, FileToReplacements,
|
|
||||||
InitialDirectory.str(), "LLVM",
|
|
||||||
Reporter != nullptr};
|
Reporter != nullptr};
|
||||||
|
|
||||||
auto Factory = llvm::make_unique<clang::move::ClangMoveActionFactory>(
|
auto Factory = llvm::make_unique<clang::move::ClangMoveActionFactory>(
|
||||||
&MoveContext, Reporter);
|
&MoveContext, Reporter);
|
||||||
|
|
||||||
|
// std::string IncludeArg = Twine("-I" + WorkingDir;
|
||||||
tooling::runToolOnCodeWithArgs(
|
tooling::runToolOnCodeWithArgs(
|
||||||
Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
|
Factory->create(), CC, Context.InMemoryFileSystem,
|
||||||
TestCCName, "clang-move", std::make_shared<PCHContainerOperations>(),
|
{"-std=c++11", "-fparse-all-comments", "-I."}, TestCCName, "clang-move",
|
||||||
FileToSourceText);
|
std::make_shared<PCHContainerOperations>());
|
||||||
formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
|
formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
|
||||||
// The Key is file name, value is the new code after moving the class.
|
// The Key is file name, value is the new code after moving the class.
|
||||||
std::map<std::string, std::string> Results;
|
std::map<std::string, std::string> Results;
|
||||||
|
|
Loading…
Reference in New Issue