diff options
author | Sam McCall <sam.mccall@gmail.com> | 2019-07-12 23:38:31 +0000 |
---|---|---|
committer | Sam McCall <sam.mccall@gmail.com> | 2019-07-12 23:38:31 +0000 |
commit | 5d9d7c59ee3353675ec89653c3a2b0175305d59a (patch) | |
tree | f9cdc43c0e8c480316d1e77a54088eb46dedece2 /clang/unittests/Tooling/CompilationDatabaseTest.cpp | |
parent | 51a52b58930cd1bb2351bf7017adfd55073f6553 (diff) | |
download | llvm-5d9d7c59ee3353675ec89653c3a2b0175305d59a.zip llvm-5d9d7c59ee3353675ec89653c3a2b0175305d59a.tar.gz llvm-5d9d7c59ee3353675ec89653c3a2b0175305d59a.tar.bz2 |
Re-land [JSONCompilationDatabase] Strip distcc/ccache/gomacc wrappers from parsed commands.
Use //net/dir like other test cases for windows compatibility
llvm-svn: 365975
Diffstat (limited to 'clang/unittests/Tooling/CompilationDatabaseTest.cpp')
-rw-r--r-- | clang/unittests/Tooling/CompilationDatabaseTest.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp index da7ae09..fde9544 100644 --- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp +++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp @@ -370,6 +370,33 @@ TEST(findCompileArgsInJsonDatabase, FindsEntry) { EXPECT_EQ("command4", FoundCommand.CommandLine[0]) << ErrorMessage; } +TEST(findCompileArgsInJsonDatabase, ParsesCompilerWrappers) { + StringRef Directory("//net/dir"); + StringRef FileName("//net/dir/filename"); + std::vector<std::pair<std::string, std::string>> Cases = { + {"distcc gcc foo.c", "gcc foo.c"}, + {"gomacc clang++ foo.c", "clang++ foo.c"}, + {"ccache gcc foo.c", "gcc foo.c"}, + {"ccache.exe gcc foo.c", "gcc foo.c"}, + {"ccache g++.exe foo.c", "g++.exe foo.c"}, + {"ccache distcc gcc foo.c", "gcc foo.c"}, + + {"distcc foo.c", "distcc foo.c"}, + {"distcc -I/foo/bar foo.c", "distcc -I/foo/bar foo.c"}, + }; + std::string ErrorMessage; + + for (const auto &Case : Cases) { + std::string DB = + R"([{"directory":"//net/dir", "file":"//net/dir/foo.c", "command":")" + + Case.first + "\"}]"; + CompileCommand FoundCommand = + findCompileArgsInJsonDatabase("//net/dir/foo.c", DB, ErrorMessage); + EXPECT_EQ(Case.second, llvm::join(FoundCommand.CommandLine, " ")) + << Case.first; + } +} + static std::vector<std::string> unescapeJsonCommandLine(StringRef Command) { std::string JsonDatabase = ("[{\"directory\":\"//net/root\", \"file\":\"test\", \"command\": \"" + |