[kdevelop/kdevelop] plugins/custom-definesandincludes/compilerprovider/tests: test_compilerprovider: add test to check if include order is preserved

Martin Bednar <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit b15ed26232c28b17be6707d1c5ed7d5e7133257d by Martin Bednar, on behalf of Benjamin ROBIN.
Committed on 21/07/2026 at 10:38.
Pushed by bednar into branch 'master'.

test_compilerprovider: add test to check if include order is preserved

The test is based on the "SimpleProject". The following sequence
is performed:
- Load the project and verify that the configured include path is as
  expected.
- Modify the include paths: Set 31 include paths in such a way that if
  the settings sort by value, the test would detect it.
- Save the project settings.
- Finally, reload the project settings and verify that the include paths
  are loaded in the expected order.

M  +37   -0    plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.cpp
M  +1    -0    plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.h

https://invent.kde.org/kdevelop/kdevelop/-/commit/b15ed26232c28b17be6707d1c5ed7d5e7133257d

diff --git a/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.cpp b/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.cpp
index 87462588c7..f293fdad9d 100644
--- a/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.cpp
+++ b/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.cpp
@@ -236,6 +236,43 @@ void TestCompilerProvider::testCompilerIncludesAndDefinesForProject()
     ICore::self()->projectController()->closeProject(project);
 }
 
+void TestCompilerProvider::testCompilerIncludesOrder()
+{
+    auto project = ProjectsGenerator::GenerateSimpleProject();
+    Q_ASSERT(project);
+
+    auto settings = SettingsManager::globalInstance();
+
+    {
+        auto entries = settings->readPaths(project->projectConfiguration().data());
+        QVERIFY(entries.length() == 1);
+
+        auto &entry = entries[0];
+        QVERIFY(entry.includes.length() == 1);
+        QVERIFY(entry.includes[0] == (QDir::rootPath() + "usr/include/mydir"));
+
+        entry.includes.clear();
+        for (int i = 0; i < 31; ++i) {
+            entry.includes += QDir::rootPath() + QString("usr/include/dir%1").arg(17 - i);
+        }
+
+        settings->writePaths(project->projectConfiguration().data(), entries);
+    }
+
+    {
+        auto entries = settings->readPaths(project->projectConfiguration().data());
+        QVERIFY(entries.length() == 1);
+
+        auto &entry = entries[0];
+        QVERIFY(entry.includes.length() == 31);
+        for (int i = 0; i < 31; ++i) {
+            QVERIFY(entry.includes[i] == (QDir::rootPath() + QString("usr/include/dir%1").arg(17 - i)));
+        }
+    }
+
+    ICore::self()->projectController()->closeProject(project);
+}
+
 QTEST_MAIN(TestCompilerProvider)
 
 #include "moc_test_compilerprovider.cpp"
diff --git a/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.h b/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.h
index 2279d0136a..36809f7645 100644
--- a/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.h
+++ b/plugins/custom-definesandincludes/compilerprovider/tests/test_compilerprovider.h
@@ -19,6 +19,7 @@ private Q_SLOTS:
     void testCompilerIncludesAndDefines();
     void testStorageBackwardsCompatible();
     void testCompilerIncludesAndDefinesForProject();
+    void testCompilerIncludesOrder();
     void testStorageNewSystem();
 };
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.