QEXTRACTTESTDATA: include the errorString() in case of failure
In case we fail to copy or set the permissions, get the error string from QFile. This necessitated fixing QFile so it would copy the error from QTemporaryFile in case the latter failed to open. Drive-by use %ls to avoid going through the locale codec in QtTest. Change-Id: Ifbf974a4d10745b099b1fffd1777c7e6e00c25af Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>bb10
parent
17f61ddc63
commit
81685b0ac0
|
|
@ -781,9 +781,9 @@ QFile::copy(const QString &newName)
|
|||
}
|
||||
#endif
|
||||
if (error) {
|
||||
d->setError(QFile::CopyError, tr("Cannot open for output: %1").arg(out.errorString()));
|
||||
out.close();
|
||||
close();
|
||||
d->setError(QFile::CopyError, tr("Cannot open for output: %1").arg(out.errorString()));
|
||||
} else {
|
||||
if (!d->engine()->cloneTo(out.d_func()->engine())) {
|
||||
char block[4096];
|
||||
|
|
|
|||
|
|
@ -2702,12 +2702,17 @@ QSharedPointer<QTemporaryDir> QTest::qExtractTestData(const QString &dirName)
|
|||
const QString destination = dataPath + u'/' + QStringView{fileInfo.filePath()}.mid(resourcePath.size());
|
||||
QFileInfo destinationFileInfo(destination);
|
||||
QDir().mkpath(destinationFileInfo.path());
|
||||
if (!QFile::copy(fileInfo.filePath(), destination)) {
|
||||
qWarning("Failed to copy '%s'.", qPrintable(fileInfo.filePath()));
|
||||
QFile file(fileInfo.filePath());
|
||||
if (!file.copy(destination)) {
|
||||
qWarning("Failed to copy '%ls': %ls.", qUtf16Printable(fileInfo.filePath()),
|
||||
qUtf16Printable(file.errorString()));
|
||||
return result;
|
||||
}
|
||||
if (!QFile::setPermissions(destination, QFile::ReadUser | QFile::WriteUser | QFile::ReadGroup)) {
|
||||
qWarning("Failed to set permissions on '%s'.", qPrintable(destination));
|
||||
|
||||
file.setFileName(destination);
|
||||
if (!file.setPermissions(QFile::ReadUser | QFile::WriteUser | QFile::ReadGroup)) {
|
||||
qWarning("Failed to set permissions on '%ls': %ls.", qUtf16Printable(destination),
|
||||
qUtf16Printable(file.errorString()));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue