Add wait to fix failure --- keepassxc-2.7.10/tests/TestDatabase.cpp.~1~ 2025-03-02 17:31:21.000000000 -0500 +++ keepassxc-2.7.10/tests/TestDatabase.cpp 2025-04-18 23:26:47.208358492 -0400 @@ -162,17 +162,20 @@ QCOMPARE(spySaved.count(), 1); // Short delay to allow file system settling to reduce test failures - Tools::wait(100); + Tools::wait(200); QSignalSpy spyFileChanged(db.data(), &Database::databaseFileChanged); QVERIFY(tempFile.copyFromFile(dbFileName)); + Tools::wait(200); QTRY_COMPARE(spyFileChanged.count(), 1); QTRY_VERIFY(!db->isModified()); db->metadata()->setName("test2"); + Tools::wait(200); QTRY_VERIFY(db->isModified()); QSignalSpy spyDiscarded(db.data(), SIGNAL(databaseDiscarded())); QVERIFY(db->open(tempFile.fileName(), key, &error)); + Tools::wait(200); QCOMPARE(spyDiscarded.count(), 1); } @@ -272,6 +275,7 @@ void TestDatabase::testExternallyModified() { TemporaryFile tempFile; + Tools::wait(200); QVERIFY(tempFile.copyFromFile(dbFileName)); auto db = QSharedPointer::create(); @@ -279,30 +283,41 @@ key->addKey(QSharedPointer::create("a")); QString error; + Tools::wait(200); QVERIFY(db->open(tempFile.fileName(), key, &error) == true); db->metadata()->setName("test2"); + Tools::wait(200); QVERIFY(db->save(Database::Atomic, {}, &error)); QSignalSpy spyFileChanged(db.data(), &Database::databaseFileChanged); + Tools::wait(200); QVERIFY(tempFile.copyFromFile(dbFileName)); + Tools::wait(200); QTRY_COMPARE(spyFileChanged.count(), 1); // the first argument of the databaseFileChanged signal (triggeredBySave) should be false QVERIFY(spyFileChanged.at(0).length() == 1); + Tools::wait(200); QVERIFY(spyFileChanged.at(0).at(0).type() == QVariant::Bool); + Tools::wait(200); QVERIFY(spyFileChanged.at(0).at(0).toBool() == false); + Tools::wait(200); spyFileChanged.clear(); // shouldn't be able to save due to external changes QVERIFY(db->save(Database::Atomic, {}, &error) == false); QApplication::processEvents(); + Tools::wait(200); // save should have triggered another databaseFileChanged signal QVERIFY(spyFileChanged.count() >= 1); // the first argument of the databaseFileChanged signal (triggeredBySave) should be true QVERIFY(spyFileChanged.at(0).at(0).type() == QVariant::Bool); + Tools::wait(200); QVERIFY(spyFileChanged.at(0).at(0).toBool() == true); // should be able to overwrite externally modified changes when explicitly requested db->setIgnoreFileChangesUntilSaved(true); + Tools::wait(200); QVERIFY(db->save(Database::Atomic, {}, &error)); + Tools::wait(200); // ignoreFileChangesUntilSaved should reset after save QVERIFY(db->ignoreFileChangesUntilSaved() == false); }