summaryrefslogtreecommitdiffstats
path: root/tests/auto/tools/qdbusxml2cpp
diff options
context:
space:
mode:
authorDavid Edmundson <davidedmundson@kde.org>2022-12-14 14:50:07 +0000
committerDavid Edmundson <davidedmundson@kde.org>2022-12-16 17:21:57 +0000
commitc7425aa2950bfd47fdf390478616d1a383528886 (patch)
tree2a7a56a185b307888b828ded52f5c296e5a04289 /tests/auto/tools/qdbusxml2cpp
parent7d0f08094a2318b753ea7d69b71c0abe0a46b3d3 (diff)
dbus: Fix path to moc file in generated qdbusxml2cpp
qdbusxml2cpp takes a filename to use for generated output. It may be in the form 'name.cpp' or just 'name'. For the moc file we need to convert this from a path to a name of a file in the same relative folder. It's not uncommon for this name to contain dots as sometimes a dbus interface name is used directly. For the cases where a suffix is not provided the whole name should be used. Pick-to: 6.5 Change-Id: I3bf4ae8b2b9121184c2786009e8b5abcc5e3e410 Reviewed-by: Mate Barany <mate.barany@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests/auto/tools/qdbusxml2cpp')
-rw-r--r--tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
index 0d30d4856e..10bb410bd2 100644
--- a/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
+++ b/tests/auto/tools/qdbusxml2cpp/tst_qdbusxml2cpp.cpp
@@ -384,6 +384,10 @@ void tst_qdbusxml2cpp::includeMoc_data()
QTest::newRow("cpp-only") << ":foo.cpp" << QByteArray("#include \"moc_foo.cpp\"")
<< QByteArray("warning: no header name is provided, assuming it to be \"foo.h\"");
QTest::newRow("header-and-cpp") << "foo_h.h:foo.cpp" << QByteArray("#include \"moc_foo_h.cpp\"") << QByteArray("");
+
+ QTest::newRow("combined-cpp with dots") << "foo.bar.cpp" << QByteArray("#include \"foo.bar.moc\"") << QByteArray("");
+ QTest::newRow("without extension with dots") << "foo.bar" << QByteArray("#include \"moc_foo.bar.cpp\"") << QByteArray("");
+ QTest::newRow("header-and-cpp with dots") << "foo.bar_h.h:foo.bar.cpp" << QByteArray("#include \"moc_foo.bar_h.cpp\"") << QByteArray("");
}
void tst_qdbusxml2cpp::includeMoc()
@@ -402,9 +406,11 @@ void tst_qdbusxml2cpp::includeMoc()
QStringList parts = filenames.split(u':');
QFileInfo first{parts.first()};
- if ((parts.size() == 1) && (!first.suffix().isEmpty())) {
+ const bool firstHasSuffix = QStringList({"h", "cpp", "cc"}).contains(first.suffix());
+
+ if ((parts.size() == 1) && firstHasSuffix) {
checkOneFile(parts.first(), expected);
- } else if ((parts.size() == 1) && (first.suffix().isEmpty())) {
+ } else if ((parts.size() == 1) && (!firstHasSuffix)) {
QString headerName{parts.first()};
headerName += ".h";
QString sourceName{parts.first()};