Skip to content

Commit db53a52

Browse files
author
Eric Liu
committed
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
1 parent 8992d27 commit db53a52

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

clang-tools-extra/unittests/clang-move/ClangMoveTests.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ namespace clang {
2424
namespace move {
2525
namespace {
2626

27-
const char TestHeaderName[] = "foo.h";
28-
29-
const char TestCCName[] = "foo.cc";
30-
3127
const char TestHeader[] = "namespace a {\n"
3228
"class C1; // test\n"
3329
"template <typename T> class C2;\n"
@@ -196,16 +192,25 @@ const char ExpectedNewCC[] = "namespace a {\n"
196192
"} // namespace b\n"
197193
"} // namespace a\n";
198194

195+
#ifdef _WIN32
196+
const char WorkingDir[] = "C:\\test";
197+
#else
198+
const char WorkingDir[] = "/test";
199+
#endif
200+
201+
const char TestHeaderName[] = "foo.h";
202+
const char TestCCName[] = "foo.cc";
203+
199204
std::map<std::string, std::string>
200205
runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
201206
const char *const Header = TestHeader,
202207
const char *const CC = TestCC,
203208
DeclarationReporter *const Reporter = nullptr) {
204209
clang::RewriterTestContext Context;
205210

211+
Context.InMemoryFileSystem->setCurrentWorkingDirectory(WorkingDir);
212+
206213
std::map<llvm::StringRef, clang::FileID> FileToFileID;
207-
std::vector<std::pair<std::string, std::string>> FileToSourceText = {
208-
{TestHeaderName, Header}, {TestCCName, CC}};
209214

210215
auto CreateFiles = [&Context, &FileToFileID](llvm::StringRef Name,
211216
llvm::StringRef Code) {
@@ -215,25 +220,21 @@ runClangMoveOnCode(const move::MoveDefinitionSpec &Spec,
215220
};
216221
CreateFiles(Spec.NewCC, "");
217222
CreateFiles(Spec.NewHeader, "");
218-
CreateFiles(Spec.OldHeader, Header);
219-
CreateFiles(Spec.OldCC, CC);
223+
CreateFiles(TestHeaderName, Header);
224+
CreateFiles(TestCCName, CC);
220225

221226
std::map<std::string, tooling::Replacements> FileToReplacements;
222-
llvm::SmallString<128> InitialDirectory;
223-
std::error_code EC = llvm::sys::fs::current_path(InitialDirectory);
224-
assert(!EC);
225-
(void)EC;
226-
ClangMoveContext MoveContext = {Spec, FileToReplacements,
227-
InitialDirectory.str(), "LLVM",
227+
ClangMoveContext MoveContext = {Spec, FileToReplacements, WorkingDir, "LLVM",
228228
Reporter != nullptr};
229229

230230
auto Factory = llvm::make_unique<clang::move::ClangMoveActionFactory>(
231231
&MoveContext, Reporter);
232232

233+
// std::string IncludeArg = Twine("-I" + WorkingDir;
233234
tooling::runToolOnCodeWithArgs(
234-
Factory->create(), CC, {"-std=c++11", "-fparse-all-comments"},
235-
TestCCName, "clang-move", std::make_shared<PCHContainerOperations>(),
236-
FileToSourceText);
235+
Factory->create(), CC, Context.InMemoryFileSystem,
236+
{"-std=c++11", "-fparse-all-comments", "-I."}, TestCCName, "clang-move",
237+
std::make_shared<PCHContainerOperations>());
237238
formatAndApplyAllReplacements(FileToReplacements, Context.Rewrite, "llvm");
238239
// The Key is file name, value is the new code after moving the class.
239240
std::map<std::string, std::string> Results;

0 commit comments

Comments
 (0)