diff --git a/src/test/ValentinaTest/abstracttest.cpp b/src/test/ValentinaTest/abstracttest.cpp index c671f4d9f..920b396a9 100644 --- a/src/test/ValentinaTest/abstracttest.cpp +++ b/src/test/ValentinaTest/abstracttest.cpp @@ -138,9 +138,11 @@ bool AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg { QDir targetDir(tgtFilePath); targetDir.cdUp(); - if (not targetDir.mkdir(QFileInfo(tgtFilePath).fileName())) + const QString dirName = QFileInfo(tgtFilePath).fileName(); + if (not targetDir.mkdir(dirName)) { - QWARN("Can't create subdir./n"); + const QString msg = QString("Can't create dir '%1'.").arg(dirName); + QWARN(qUtf8Printable(msg)); return false; } QDir sourceDir(srcFilePath); @@ -158,9 +160,26 @@ bool AbstractTest::CopyRecursively(const QString &srcFilePath, const QString &tg } else { + if (QFileInfo(tgtFilePath).exists()) + { + const QString msg = QString("File '%1' exists.").arg(srcFilePath); + QWARN(qUtf8Printable(msg)); + + if (QFile::remove(tgtFilePath)) + { + QWARN("File successfully removed."); + } + else + { + QWARN("Can't remove file."); + return false; + } + } + if (not QFile::copy(srcFilePath, tgtFilePath)) { - QWARN("Can't copy file./n"); + const QString msg = QString("Can't copy file '%1' to '%2'.").arg(srcFilePath).arg(tgtFilePath); + QWARN(qUtf8Printable(msg)); return false; } }