[kdevelop/kdevelop/release/26.08] plugins/custom-definesandincludes/compilerprovider/tests: test_compilerprovider: add test to check if include order is preserved
Martin Bednár <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit a57ea5ad55036f43ee4e02a8e5573af08121f5b2 by Martin Bednár, on behalf of Benjamin ROBIN.
Committed on 21/07/2026 at 10:43.
Pushed by bednar into branch 'release/26.08'.
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/a57ea5ad55036f43ee4e02a8e5573af08121f5b2
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();
};