@@ -62,6 +62,7 @@ class TestImportProject : public TestFixture {
62
62
TEST_CASE (importCompileCommands9);
63
63
TEST_CASE (importCompileCommands10); // #10887: include path with space
64
64
TEST_CASE (importCompileCommands11); // include path order
65
+ TEST_CASE (importCompileCommands12); // #13040: "directory" is parent directory, relative include paths
65
66
TEST_CASE (importCompileCommandsArgumentsSection); // Handle arguments section
66
67
TEST_CASE (importCompileCommandsNoCommandSection); // gracefully handles malformed json
67
68
TEST_CASE (importCppcheckGuiProject);
@@ -319,6 +320,23 @@ class TestImportProject : public TestFixture {
319
320
ASSERT_EQUALS (" /x/abc/" , fs.includePaths .back ());
320
321
}
321
322
323
+ void importCompileCommands12 () const { // #13040
324
+ REDIRECT;
325
+ constexpr char json[] =
326
+ R"( [{
327
+ "file": "/x/src/1.c" ,
328
+ "directory": "/x",
329
+ "command": "cc -c -I. src/1.c"
330
+ }])" ;
331
+ std::istringstream istr (json);
332
+ TestImporter importer;
333
+ ASSERT_EQUALS (true , importer.importCompileCommands (istr));
334
+ ASSERT_EQUALS (1 , importer.fileSettings .size ());
335
+ const FileSettings &fs = importer.fileSettings .front ();
336
+ ASSERT_EQUALS (1 , fs.includePaths .size ());
337
+ ASSERT_EQUALS (" /x/" , fs.includePaths .front ());
338
+ }
339
+
322
340
void importCompileCommandsArgumentsSection () const {
323
341
REDIRECT;
324
342
constexpr char json[] = " [ { \" directory\" : \" /tmp/\" ,"
0 commit comments