From 86be2b303ee6ebb93873bc952c51fda4e04bf70d Mon Sep 17 00:00:00 2001 From: Andre Rummler Date: Sun, 4 Oct 2026 10:28:15 +0200 Subject: [PATCH] Fix qtest regarding hash stability as requested in PR #1282. --- tests/qttest/CMakeLists.txt | 12 ++++++++++++ tests/qttest/tst_resaveunchanged.cpp | 3 +++ 2 files changed, 15 insertions(+) diff --git a/tests/qttest/CMakeLists.txt b/tests/qttest/CMakeLists.txt index d845df4fd..eb1f4ff1d 100644 --- a/tests/qttest/CMakeLists.txt +++ b/tests/qttest/CMakeLists.txt @@ -726,3 +726,15 @@ add_executable( add_test(NAME tst_xrefpos COMMAND tst_xrefpos) target_include_directories(tst_xrefpos PRIVATE ${QET_DIR}/sources) target_link_libraries(tst_xrefpos PRIVATE Qt::Test Qt::Widgets Qt::Xml pugixml::pugixml) + +# Qt 6.4.2 writes the attributes of an element in an order that changes from +# one process to the next, so a project saved twice by two runs of the binary +# differs in bytes only (seen on projects without any numbering, too). A fixed +# hash seed makes the order stable; it changes nothing for a newer Qt. +if(Qt6_VERSION VERSION_LESS 6.5.0) + foreach(qet_test tst_resaveunchanged tst_elementautonumids) + if(TEST ${qet_test}) + set_tests_properties(${qet_test} PROPERTIES ENVIRONMENT "QT_HASH_SEED=0") + endif() + endforeach() +endif() diff --git a/tests/qttest/tst_resaveunchanged.cpp b/tests/qttest/tst_resaveunchanged.cpp index 042a934d6..bc333ea44 100644 --- a/tests/qttest/tst_resaveunchanged.cpp +++ b/tests/qttest/tst_resaveunchanged.cpp @@ -122,6 +122,9 @@ private slots: // (#973), and a value with accents comes back as it went in. void singleSpaceValueKept() { +#if QT_VERSION < QT_VERSION_CHECK(6, 5, 0) + QSKIP("QDomDocument::PreserveSpacingOnlyNodes needs Qt 6.5 (see QETProject::openFile)"); +#endif QByteArray xml = read(QStringLiteral(QET_EXAMPLES_DIR "/Projet_vierge.qet")); QVERIFY(xml.contains("")); xml.replace("",