From a116360f87e7b1897472569509d54f7592b59d29 Mon Sep 17 00:00:00 2001 From: WarmUpTill <19472752+WarmUpTill@users.noreply.github.com> Date: Wed, 29 Apr 2026 22:54:17 +0200 Subject: [PATCH] Tests: Handle QFile::open() return value --- tests/test-macro-condition-file.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/test-macro-condition-file.cpp b/tests/test-macro-condition-file.cpp index 495af16e..6330f64e 100644 --- a/tests/test-macro-condition-file.cpp +++ b/tests/test-macro-condition-file.cpp @@ -13,7 +13,10 @@ using advss::MacroConditionFile; static void writeFile(const QString &path, const QString &content) { QFile f(path); - f.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate); + if (!f.open(QIODevice::WriteOnly | QIODevice::Text | + QIODevice::Truncate)) { + return; + } QTextStream(&f) << content; } @@ -155,7 +158,9 @@ TEST_CASE("DATE_CHANGE: triggers when modification date changes", // Explicitly set the modification time to a known future value so the // test is not sensitive to filesystem mtime resolution. QFile f(path); - f.open(QIODevice::ReadWrite); + if (!f.open(QIODevice::ReadWrite)) { + return; + } f.setFileTime(QDateTime::currentDateTime().addSecs(10), QFileDevice::FileModificationTime); f.close();