summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Tooling
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-09-22 17:22:33 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2015-09-22 17:22:33 +0000
commit64f67be319f0af7f276ded9f3bd8e0afc288563c (patch)
treeeda8bef7206e75c89c74e74b663f9e07d926f03e /clang/unittests/Tooling
parent07a844d758f09e1dd07ca17eb38a22d69d63fae3 (diff)
downloadbcm5719-llvm-64f67be319f0af7f276ded9f3bd8e0afc288563c.tar.gz
bcm5719-llvm-64f67be319f0af7f276ded9f3bd8e0afc288563c.zip
[tooling] Provide the compile commands of the JSON database in the order that they were provided in the JSON file.
This is useful for debugging of issues and reduction of test cases. For example, an issue may show up due to the order that some commands were processed. It is convenient to be able to remove commands from the file and still preserve the order that they are returned, instead of getting a completely different order when removing a few commands. llvm-svn: 248292
Diffstat (limited to 'clang/unittests/Tooling')
-rw-r--r--clang/unittests/Tooling/CompilationDatabaseTest.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/unittests/Tooling/CompilationDatabaseTest.cpp b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
index b7e7a72d235..380d86fc566 100644
--- a/clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ b/clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -118,6 +118,25 @@ TEST(JSONCompilationDatabase, GetAllCompileCommands) {
EXPECT_EQ(FileName2, Commands[1].Filename) << ErrorMessage;
ASSERT_EQ(1u, Commands[1].CommandLine.size());
EXPECT_EQ(Command2, Commands[1].CommandLine[0]) << ErrorMessage;
+
+ // Check that order is preserved.
+ Commands = getAllCompileCommands(
+ ("[{\"directory\":\"" + Directory2 + "\"," +
+ "\"command\":\"" + Command2 + "\","
+ "\"file\":\"" + FileName2 + "\"},"
+ " {\"directory\":\"" + Directory1 + "\"," +
+ "\"command\":\"" + Command1 + "\","
+ "\"file\":\"" + FileName1 + "\"}]").str(),
+ ErrorMessage);
+ EXPECT_EQ(2U, Commands.size()) << ErrorMessage;
+ EXPECT_EQ(Directory2, Commands[0].Directory) << ErrorMessage;
+ EXPECT_EQ(FileName2, Commands[0].Filename) << ErrorMessage;
+ ASSERT_EQ(1u, Commands[0].CommandLine.size());
+ EXPECT_EQ(Command2, Commands[0].CommandLine[0]) << ErrorMessage;
+ EXPECT_EQ(Directory1, Commands[1].Directory) << ErrorMessage;
+ EXPECT_EQ(FileName1, Commands[1].Filename) << ErrorMessage;
+ ASSERT_EQ(1u, Commands[1].CommandLine.size());
+ EXPECT_EQ(Command1, Commands[1].CommandLine[0]) << ErrorMessage;
}
static CompileCommand findCompileArgsInJsonDatabase(StringRef FileName,
OpenPOWER on IntegriCloud