Handle disk full situations by skipping QFile::moveToTrash test
If any of the temporary directories and files can't be created, skip the test. Otherwise, the cleanup routine would recursively delete "/". Change-Id: I51f908a468be8fd2ebd523ff7ce27a7c78d1b4e2 Fixes: QTBUG-83863 Pick-to: 5.15 Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
a033c23ddf
commit
9b4b406142
@ -3677,11 +3677,14 @@ void tst_QFile::moveToTrash_data()
|
||||
// success cases
|
||||
{
|
||||
QTemporaryFile temp;
|
||||
QVERIFY(temp.open());
|
||||
if (!temp.open())
|
||||
QSKIP("Failed to create temporary file!");
|
||||
QTest::newRow("temporary file") << temp.fileName() << true << true;
|
||||
}
|
||||
{
|
||||
QTemporaryDir tempDir;
|
||||
if (!tempDir.isValid())
|
||||
QSKIP("Failed to create temporary directory!");
|
||||
tempDir.setAutoRemove(false);
|
||||
QTest::newRow("temporary dir")
|
||||
<< tempDir.path() + QLatin1Char('/')
|
||||
@ -3689,10 +3692,13 @@ void tst_QFile::moveToTrash_data()
|
||||
}
|
||||
{
|
||||
QTemporaryDir homeDir(QDir::homePath() + QLatin1String("/XXXXXX"));
|
||||
homeDir.setAutoRemove(false);
|
||||
if (!homeDir.isValid())
|
||||
QSKIP("Failed to create temporary directory in $HOME!");
|
||||
QTemporaryFile homeFile(homeDir.path()
|
||||
+ QLatin1String("/tst_qfile-XXXXXX"));
|
||||
homeFile.open();
|
||||
if (!homeFile.open())
|
||||
QSKIP("Failed to create temporary file in $HOME");
|
||||
homeDir.setAutoRemove(false);
|
||||
QTest::newRow("home file")
|
||||
<< homeFile.fileName()
|
||||
<< true << true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user